/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
// your code goes here
findPrimes(25);
}
static void findPrimes(int limit) {
// Special handling for 2
if (limit > 2)
// Loop from the first Prime till limit
for (int i = 2; i < limit; i++) {
// Assume number to be prime
boolean isPrime = true;
if (i % 2 == 0)
isPrime = false;
else {
// Loop from 3 to number/2
for (int j = 3; j < i / 2; j += 2) {
// If the number divides, it means the number is not prime
if (i % j == 0) {
isPrime = false;
break;
}
}
}
// Print the number if it is prime
if (isPrime)
}
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCS8vIHlvdXIgY29kZSBnb2VzIGhlcmUKCQlmaW5kUHJpbWVzKDI1KTsKCX0KCQoJc3RhdGljIHZvaWQgZmluZFByaW1lcyhpbnQgbGltaXQpIHsKCiAgICAgICAgLy8gU3BlY2lhbCBoYW5kbGluZyBmb3IgMgogICAgICAgIGlmIChsaW1pdCA+IDIpCiAgICAgICAgICAgIFN5c3RlbS5vdXQucHJpbnQoIjIsIik7CgogICAgICAgIC8vIExvb3AgZnJvbSB0aGUgZmlyc3QgUHJpbWUgdGlsbCBsaW1pdAogICAgICAgIGZvciAoaW50IGkgPSAyOyBpIDwgbGltaXQ7IGkrKykgewogICAgICAgICAgICAvLyBBc3N1bWUgbnVtYmVyIHRvIGJlIHByaW1lCiAgICAgICAgICAgIGJvb2xlYW4gaXNQcmltZSA9IHRydWU7CgogICAgICAgICAgICBpZiAoaSAlIDIgPT0gMCkKICAgICAgICAgICAgICAgIGlzUHJpbWUgPSBmYWxzZTsKICAgICAgICAgICAgZWxzZSB7CgogICAgICAgICAgICAgICAgLy8gTG9vcCBmcm9tIDMgdG8gbnVtYmVyLzIKICAgICAgICAgICAgICAgIGZvciAoaW50IGogPSAzOyBqIDwgaSAvIDI7IGogKz0gMikgewoKICAgICAgICAgICAgICAgICAgICAvLyBJZiB0aGUgbnVtYmVyIGRpdmlkZXMsIGl0IG1lYW5zIHRoZSBudW1iZXIgaXMgbm90IHByaW1lCiAgICAgICAgICAgICAgICAgICAgaWYgKGkgJSBqID09IDApIHsKICAgICAgICAgICAgICAgICAgICAgICAgaXNQcmltZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8vIFByaW50IHRoZSBudW1iZXIgaWYgaXQgaXMgcHJpbWUKICAgICAgICAgICAgaWYgKGlzUHJpbWUpCiAgICAgICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50KGkgKyAiLCIpOwogICAgICAgIH0KICAgIH0KfQ==