-2
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 amount of prime numbers between i and what the user types. Any suggestions for a better algorithm? Gave error of Parsing...
What are you trying to do with it here
y = x.Scanner();?– user28595
Misspelled --' kk should be y = x.nextInt();
– Filipe Teixeira
This will not compile, this for is with wrong syntax
– user28595
and how I could fix it?
– Filipe Teixeira