Skip to content

Instantly share code, notes, and snippets.

@jingning42
Forked from cuihaoleo/fib_C.c
Last active August 29, 2015 14:06
Show Gist options
  • Save jingning42/148f01c8973011113369 to your computer and use it in GitHub Desktop.
Save jingning42/148f01c8973011113369 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main ()
{
int a = 0, b = 1, c = 1, sum = 0;
while (c < 4000000)
{
if (c % 2 == 0)
sum += c;
c = a + b;
a = b;
b = c;
}
printf("%d\n", sum);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment