0

Simple program to check whether a number is prime or not. Something is seriously wrong because every result I get is 'false'. Help me out please. Thanks in advance.

class primeTesting {
	public static void main(String[] args){
		int i=7; //changing the value everytime always gives false.... ???
		boolean bool=false;
		for(int c=i-1;c>1;c--){
			if(c%i==0){
				bool=true;
				break;
				
			}
		}
		System.out.println(""+bool);
	}
}

Edited by guyfrompluto: n/a

1
Contributor
1
Reply
2
Views
7 Years
Discussion Span
Last Post by guyfrompluto
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.