Problem 10 of Find the sum of all the primes below two million.
来源:互联网 发布:华东交大软件学院吧 编辑:程序博客网 时间:2024/06/05 21:08
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
public class BigPrime {public static void main(String args[]){long j=0;for(long i=2;i<2000000;i++){if(isPrime(i)){j+=i;}}System.out.println(j);}public static boolean isPrime(long n){ for(int i = 2; i * i <= n; i++){ if(n % i == 0) return false; } return true;}}
Answer:
142913828922- Problem 10 of Find the sum of all the primes below two million.
- Problem 1:Find the sum of all the multiples of 3 or 5 below 1000.
- Problem 21 of Evaluate the sum of all the amicable numbers under 10000.
- find all the permutation of a string
- Find the all applications of ubuntu
- the sum of two fixed value
- The reversed sum of two reversed numbers
- hdu 1231, dp ,maximum consecutive sum of integers, find the boundaries, possibly all negative, C++
- A Tale of Twenty-Two Million Citi Bikes: Analyzing the NYC Bike Share System
- find the two same numbers in 1 million random numbers
- geeksforgeeks Find the maximum path sum between two leaves of a binary tree
- All of the previous
- The Beginning Of All
- 21.Examine the description of the EMP_DETAILS table given below:
- Problem 10:Summation of primes
- Problem 10:Summation of primes
- Problem 10 Summation of primes
- Ch8.3: find all the subsets of a set
- Shellcode检测技术参考文章
- java层aidl细节_ipc & ibinder-binder & aidl
- SPList.GetItemById(int)和SPList.Items.GetItemById(int)的区别
- USB协议深入分析 设备描述符配置包 和 返回设备描述符
- PHP页面之间传递参数的四种方式
- Problem 10 of Find the sum of all the primes below two million.
- 【碎碎念】20120313
- 数据结构算法学习--排序方法
- sqlserver2005导出成Excel2003表
- 关于写博客
- 《学习openCV》例程解析 ex_9_2(背景减除)
- Android Toast大全(五种情形)建立属于你自己的Toast
- 使用pdb调试python程序
- android源码编译与开发:问题记录