Annotation of 42BSD/usr.lib/learn/C/L17.1c, revision 1.1

1.1     ! root        1: #print
        !             2: Print the 20 Fibonacci numbers beginning with 2
        !             3: (the sequence is 2,3,5,8,... where each number
        !             4: is the sum of the immediately preceding pair of numbers.
        !             5: Start with the pair 1,1).
        !             6: Print each number on a separate line as a five digit
        !             7: number (remember %3d in printf? %5d does five digits).
        !             8: Compile and test your program; then type "ready".
        !             9: #once #create Ref
        !            10:     2
        !            11:     3
        !            12:     5
        !            13:     8
        !            14:    13
        !            15:    21
        !            16:    34
        !            17:    55
        !            18:    89
        !            19:   144
        !            20:   233
        !            21:   377
        !            22:   610
        !            23:   987
        !            24:  1597
        !            25:  2584
        !            26:  4181
        !            27:  6765
        !            28: 10946
        !            29: 17711
        !            30: #user
        !            31: a.out >xxx
        !            32: #cmp xxx Ref
        !            33: #succeed
        !            34: /*      one way */
        !            35: main()
        !            36: {
        !            37:        int f1, f2, t, count;
        !            38: 
        !            39:        f1 = 1;
        !            40:        f2 = 1;
        !            41:        for (count = 0; count < 20; count++) {
        !            42:                t = f1+f2;
        !            43:                f1 = f2;
        !            44:                f2 = t;
        !            45:                printf("%5d\n", t);
        !            46:        }
        !            47: }
        !            48: #log
        !            49: #next
        !            50: 18.1a 10

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.