Recent Posts
PAWN | 1 min ago
None | 1 min ago
None | 1 min ago
Per | 2 min ago
None | 2 min ago
None | 2 min ago
T-SQL | 2 min ago
XML | 2 min ago
T-SQL | 2 min ago
None | 2 min ago
Sitereport
Find cool info about any domain on the internet?
visit sitereport
Free Subdomains
Want a pastebin.com sub-domain for your community?
learn more...
What is pastebin?
Pastebin is a website that hosts all your text & code on dedicated servers for easy sharing.
learn more...
By Anonymous on the 10th of Feb 2010 12:11:09 AM
Download |
Raw |
Embed |
Report
//Find the sum of all the primes below two million.
package problem10;
public class Problem10 {
public static void main
(String[] args
) {
long sum = 0;
for (long i = 0; i < 2000000; i++) {
if (isPrime(i)) {
sum += i;
}
if (i % 10000 == 0) {
}
}
}
public static boolean isPrime(long n) {
long i = 2;
while (i < n) {
if (n % i == 0) {
return false;
}
i++;
}
return true;
}
}
//142913828923
//9223372036854775808
Submit a correction or amendment below.
Make A New Post