Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Java by registered user redtoro ( 11 years ago )
import java.util.Arrays;
public class task4 {
static int n = 30000;
static boolean[] primes = new boolean[n];
public static void main(String[] args) {
Arrays.fill(primes, true);
primes[0] = primes[1] = false;
for (int i = 2; i < primes.length; i++) {
if (primes[i]) {
for (int j = 2; i * j < primes.length; j++) {
primes[i * j] = false;
}
}
}
for (int i = 10000; i <= 99999; i++) {
if ((primes[i]) && ((i % 10) + ((i % 100) / 10) + ((i % 1000) / 100) + ((i / 1000) % 10) + (i / 10000)) > (((i - 1) % 10) + (((i - 1) % 100) / 10) + (((i - 1) % 1000) / 100) + (((i - 1) / 1000) % 10) + ((i - 1) / 10000))) {
i = i + 1;
}
}
System.out.println (i);
}
}
Revise this Paste