Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Prime Numbers
// Java Coding Challenge - 03: Print out prime numbers 0 - 100 class Rextester { public static boolean isPrime(int prime_number) { if (prime_number <= 1) return false; //1 is not prime number if (prime_number == 2) return true; //2 is only even prime number if (prime_number % 2 == 0) return false; //excluding all even number for (int i = 2; i < prime_number; i++) { if (prime_number % i == 0) return false; } return true; } public static void main(String[] args) { int max = 100; for (int i = 1; i <= max; i++) { if (isPrime(i)) {System.out.print(i + ", "); }} }}
run
|
edit
|
history
|
help
0
Coding Challenge - 03 (Prime numbers)
Sort
Granite Java
Problem: rstring
test1
namingVariables
ekse
191fa07050
"encryption"
[a-zA-Z ]{0,12}