one-file-projects/euler2.c

15 lines
328 B
C

#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;
}