Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A program to display the Fibonacci sequence, characterised by the fact that every number after the first two is the sum of the two preceding ones
/****************************************************************************
* fibonacci.c
*
* Display the Fibonacci sequence, characterised by the fact that every number
* after the first two is the sum of the two preceding ones
***************************************************************************/
#include <stdio.h>
int main(void)
{
int a = 0;
int b = 1;
int x = 0;
while(b < 5000)
{
printf("%d\n", a);
x = b;
b = a+b;
a = x;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment