problem 10 done, and problem 7 rewritten (new is_prime algorithm)
This commit is contained in:
parent
8498165fef
commit
2ba8a8aaeb
4 changed files with 64 additions and 36 deletions
25
p10.c
Normal file
25
p10.c
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
/*
|
||||
* http://projecteuler.net
|
||||
*
|
||||
* Projecteuler - Problem 10
|
||||
* ------------------------
|
||||
* 2010-04-06 Henrik Hautakoski
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include "lib/prime.h"
|
||||
|
||||
int main() {
|
||||
|
||||
uint32_t i;
|
||||
uint64_t s = 2;
|
||||
|
||||
for(i=3; i < 2e6; i+=2) {
|
||||
if (is_prime(i))
|
||||
s += i;
|
||||
}
|
||||
printf("%lli\n", s); /* this format throws som warnings but works so whatever */
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue