projectEuler pro10
Problem 10
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
JAVA:
public class P010 {
public static void main(String[] args){
long sum = 0;
for(int i=2;i<2000000;i++){
if(isprime(i)){
sum+=i;
}
}
System.out.print(sum);
}
public static boolean isprime(int n){
for(int i=2;i*i<=n;i++){
if(n%i==0){
return false;
}
}
return true;
}
}
posted on 2013-10-09 21:38 Monster_Ch 阅读(197) 评论(0) 编辑 收藏 举报