class FindPrime {
public static void main(String args[]) {
int num;
boolean isPrime = true;
num = 14;
for(int i=2; i <= num/2; i++) {
if((num % i) == 0) {
isPrime = false;
break;
}
}
if(isPrime) System.out.println("Prime");
else System.out.println("Not Prime");
}
}
Tuesday, June 3, 2008
FInd Prime number in java
Subscribe to:
Post Comments (Atom)
1 comment:
hI,
i got it.. it worked for me.. thnaks for sharing this code.. it solved my problem..
Post a Comment