Permalink
Cannot retrieve contributors at this time
18 lines (17 sloc)
382 Bytes
|
public class Prime { |
|
fun int isPrime(int n) { |
|
if (n < 2) { |
|
return 0; |
|
} else { |
|
Math.sqrt(n) $ int => int upper; |
|
2 => int i; |
|
while (i <= upper) { |
|
if (n % i == 0) { |
|
return 0; |
|
} |
|
i++; |
|
} |
|
|
|
return 1; |
|
} |
|
} |
|
} |
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session.
You signed out in another tab or window. Reload to refresh your session.