Parsing error [duplicate]

-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 number of prime numbers between i and what the user types. Any suggestions for a better algorithm? You gave parsing error ...

    
asked by anonymous 20.08.2016 / 20:21

1 answer

0

The syntax of the for is wrong. You should do:

for(i = 1; i <= y; i++)
    
20.08.2016 / 20:28