(Problem 10)Summation of primes
来源:互联网 发布:三峡宜昌广电网络 编辑:程序博客网 时间:2024/04/30 13:53
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
#include<stdio.h>#include<string.h>#include<math.h>#include<ctype.h>#include<stdlib.h>#include<stdbool.h>#define N 2000000bool prim(int n){int i;for(i=2; i*i<=n; i++){if(n%i==0)return false;}return true;}int main(){int i;long long sum=2;for(i=3; i<=N; i=i+2){if(prim(i)){sum+=i;}}printf("%lld\n",sum);return 0;}
Answer:
142913828922
- (Problem 10)Summation of primes
- Problem 10:Summation of primes
- Problem 10:Summation of primes
- Problem 10 Summation of primes
- 【Project Euler】【Problem 10】Summation of primes
- project euler problem 10:Summation of primes
- projecteuler---->problem=10----Summation of primes
- Problem 10 Summation of primes (素数和)
- Project Euler Problem 10: Summation of primes
- PE 10 Summation of primes
- 欧拉计划(10)Summation of primes
- 10 Summation of primes - Project Euler
- project euler 10 Summation of primes
- summation of four primes
- UVa Problem 10168 Summation of Four Primes (四素数之和)
- UVa Problem Solution: 10168 - Summation of Four Primes
- 110705 Summation of Four Primes
- Summation of Four Primes - PC110705
- 开博客了
- uva 10344 23 out of 5 凑运算结果 全排列+dfs
- Web前端开发人员的面试要点
- PHP分页原理是什么?如何实现
- eclipse非正常关闭导致重新启动不了
- (Problem 10)Summation of primes
- TCP回射程序(I/O复用 select)
- .tar.xz文件的解压
- php编程,写一个函数,能够遍历一个文件夹下的所有文件和子文件夹
- hdu 4466 Triangle (12年成都区域现场赛c题)(dp+组合数学)
- 处处是可怕的灾难、
- 字符串16进制存储
- ZOJ 1076 最长上升子序列
- HDU 4473 Exam 2012成都现场赛J题(规律+思维)