diff options
Diffstat (limited to 'reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c')
-rw-r--r-- | reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c b/reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c new file mode 100644 index 0000000..6b5e8f2 --- /dev/null +++ b/reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c @@ -0,0 +1,25 @@ +#include <stdio.h> +int old_number; /* previous Fibonacci number */ + +int current_number; /* current Fibonacci number */ + +int next_number; /* next number in the series */ + +main() +{ + /* start things out */ + old_number = 1; + current_number = 1; + + (void)printf("1\n"); /* Print first number */ + + while (current_number < 100) { + + (void) printf("%d\n", current_number); + next_number = current_number + old_number; + + old_number = current_number; + current_number = next_number; + } + return (0); +} |