summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/OR_PRACTICAL_C/05_1.c
blob: 6b5e8f207567c67dbd2d060936606e9577b30bf6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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);
}