Smooth solution for 2nd euler problem

This commit is contained in:
madmaurice 2015-11-13 02:42:54 +01:00
parent a5ee847442
commit c8bef3769b
1 changed files with 15 additions and 0 deletions

15
euler2.c Normal file
View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main( int argc, char *argv[] ) {
int fib_even=2,fib_prev=1,fib_tmp;
int sum=0;
while(fib_even < 4e6) {
sum += fib_even;
fib_tmp = fib_prev + fib_even;
fib_prev = fib_even + fib_tmp;
fib_even = fib_prev + fib_tmp;
}
printf("%d\n",sum);
return 0;
}