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);
	}
}

So sorry it should have been i%c instead of c% i in Line 6. Sorry again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.