I wrote the code below:
import java.lang.Math;
import.util.Scanner;
public class HelloWorld
{
public static void main(String[] args)
{
int y;
int cont;
int i;
Scanner x = new.Scanner(System.in);
System.out.print("Digite um número");
y = x.Scanner();
for(i = 1 to y) {
if (y%i == 1){
cont++;
}
if (y%i == 2){
cont++;
}
} else{
System.out.print("O número "+i+" nao e primo");
}
System.out.print(cont)
}
}
I'm developing an algorithm to count the number of prime numbers between i and what the user types. Any suggestions for a better algorithm? You gave parsing error ...