init p1 to p9
This commit is contained in:
commit
8498165fef
9 changed files with 371 additions and 0 deletions
29
p2.c
Normal file
29
p2.c
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
/*
|
||||
* http://projecteuler.net
|
||||
*
|
||||
* Projecteuler - Problem 2
|
||||
* -----------------------
|
||||
* 2008-03-11 Henrik Hautakoski
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int main() {
|
||||
|
||||
int c = 0, a = 1, b = 1, r = 0;
|
||||
|
||||
while(c < 4000000) {
|
||||
|
||||
c = a+b;
|
||||
a = b;
|
||||
b = c;
|
||||
|
||||
if((c % 2) == 0)
|
||||
r += c;
|
||||
}
|
||||
|
||||
printf("%i\n", r);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue