0
consider the following sample input / output. Input: java is Prime 29996224275833 Output: 29996224275833 is a prime number. In
please all code
9 Respuestas
+ 1
The rest should be easy if you've done the Java base module.
public static boolean isPrime(long x){
for(long i = 2; i <= Math.sqrt(x); i++){
if(x%i == 0){
return false;
}
}
return true;
}
Edit again: Woops, my mistake there, it's supposed to be x%i ...
0
this code is not working for given input robobrine
0
Have you used the corrected version? Had a little mistake at the if.
0
when I am entering 29996224275833 I am getting InputMismatchexception
0
it fine working for small input number but for that number given error
0
Do you scan for longs?
0
thanks
- 1
Input:
java isPrime 29996224275833
Output:
29996224275833 is a prime number.
Input:
java isPrime 29996224275834
Output:
29996
- 1
please correct code give me