0

this program just prints out prime number within the range of the for loop. however it doesn't print anything.

boolean prime;
		
	for(int i = 11; i < 100; i++){
	        prime = isPrime(i); //this method works as i tested it before
		if(prime){
		    System.out.println(i);
		}
	}

everytime i run this program, nothing prints out. the method that i use works if i enter a single number and it would tell me if it's a prime number or not.

Edited by plasticfood: n/a

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by plasticfood
0

and what does your isPrime(int) method looks like ?
and i++ is a waste of time is useless :) i += 2 will do it no need to test all even numbers

Edited by pbl: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.