/**
* Author:- nikhil.lohia
*/
class Ideone {
public Ideone() {
}
public static void main
(String[] args
) { Ideone method3 = new Ideone();
// Code obtained from http://w...content-available-to-author-only...s.com
// Feel free to copy but please acknowledge wherever possible
method3.findPrimes(25);
}
private void findPrimes(int limit) {
int[] primes = new int[100];
// Special handling for the integer '2'
primes[0] = 2;
// Number of primes encountered
int primeCount = 1;
// Looping from 3, to the limit
for (int i = 3; i < limit; i++) {
boolean isPrime = true;
if (i % 2 == 0) {
continue;
}
for (int j = 0; j < primeCount; j++) {
if (i % primes[j] == 0) {
isPrime = false;
}
}
// Store the prime number and increment the count
if (isPrime) {
primes[primeCount++] = i;
}
}
// Print the primes
for (int x : primes)
if (x != 0)
}
}
LyoqCiAqIEF1dGhvcjotIG5pa2hpbC5sb2hpYQogKi8KY2xhc3MgSWRlb25lIHsKCiAgICBwdWJsaWMgSWRlb25lKCkgewogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBJZGVvbmUgbWV0aG9kMyA9IG5ldyBJZGVvbmUoKTsKICAgICAgICAvLyBDb2RlIG9idGFpbmVkIGZyb20gaHR0cDovL3cuLi5jb250ZW50LWF2YWlsYWJsZS10by1hdXRob3Itb25seS4uLnMuY29tCiAgICAgICAgLy8gRmVlbCBmcmVlIHRvIGNvcHkgYnV0IHBsZWFzZSBhY2tub3dsZWRnZSB3aGVyZXZlciBwb3NzaWJsZQogICAgICAgIG1ldGhvZDMuZmluZFByaW1lcygyNSk7CiAgICB9CgogICAgcHJpdmF0ZSB2b2lkIGZpbmRQcmltZXMoaW50IGxpbWl0KSB7CiAgICAgICAgaW50W10gcHJpbWVzID0gbmV3IGludFsxMDBdOwoKICAgICAgICAvLyBTcGVjaWFsIGhhbmRsaW5nIGZvciB0aGUgaW50ZWdlciAnMicKICAgICAgICBwcmltZXNbMF0gPSAyOwoKICAgICAgICAvLyBOdW1iZXIgb2YgcHJpbWVzIGVuY291bnRlcmVkCiAgICAgICAgaW50IHByaW1lQ291bnQgPSAxOwoKICAgICAgICAvLyBMb29waW5nIGZyb20gMywgdG8gdGhlIGxpbWl0CiAgICAgICAgZm9yIChpbnQgaSA9IDM7IGkgPCBsaW1pdDsgaSsrKSB7CiAgICAgICAgICAgIGJvb2xlYW4gaXNQcmltZSA9IHRydWU7CgogICAgICAgICAgICBpZiAoaSAlIDIgPT0gMCkgewogICAgICAgICAgICAgICAgY29udGludWU7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgcHJpbWVDb3VudDsgaisrKSB7CiAgICAgICAgICAgICAgICBpZiAoaSAlIHByaW1lc1tqXSA9PSAwKSB7CiAgICAgICAgICAgICAgICAgICAgaXNQcmltZSA9IGZhbHNlOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CgogICAgICAgICAgICAvLyBTdG9yZSB0aGUgcHJpbWUgbnVtYmVyIGFuZCBpbmNyZW1lbnQgdGhlIGNvdW50CiAgICAgICAgICAgIGlmIChpc1ByaW1lKSB7CiAgICAgICAgICAgICAgICBwcmltZXNbcHJpbWVDb3VudCsrXSA9IGk7CiAgICAgICAgICAgIH0KICAgICAgICB9CgogICAgICAgIC8vIFByaW50IHRoZSBwcmltZXMKICAgICAgICBmb3IgKGludCB4IDogcHJpbWVzKQogICAgICAgICAgICBpZiAoeCAhPSAwKQogICAgICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludCh4ICsgIiwiKTsKICAgIH0KCn0=