idea here is to have user input an int n and find the prime numbers between 2 and n. then print out how many prime numbers there are for example.. 2-100 = 25 prime numbers. i cant figure out whats wrong with this so far. somehow i get high numbers when i run this program. help pls? .
public class Prime { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n; String choice; do { System.out.print("Enter in value for n: "); n = scanner.nextInt(); int primes = 0; for(int i=3; i<=n; i++) { for(int j=2; j<i; j++) { if(i%j == 0){} else{ primes = primes +1;} } } System.out.println("Number of primes: " +primes); System.out.println("Do you want to continue? Y/N: "); choice = scanner.next(); }while (choice.equalsIgnoreCase("Y")); } }