Created
June 6, 2017 05:04
-
-
Save jonenzl/a0ba37b76cf0ec95f786156de2ff796b to your computer and use it in GitHub Desktop.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /**************************************************************************** | |
| * 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