progs/fib.while
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Fri, 27 Sep 2013 15:43:25 +0100
changeset 116 010ae7288327
parent 93 4794759139ea
child 147 4725bba8ef26
permissions -rw-r--r--
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
80
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
     1
/* Fibonacci Program
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
     2
   input: n
84
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
     3
*/
75
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 73
diff changeset
     4
83
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 80
diff changeset
     5
n := 19;
75
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 73
diff changeset
     6
minus1 := 0;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 73
diff changeset
     7
minus2 := 1;
80
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 76
diff changeset
     8
while n > 0 do {
73
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
     9
       temp := minus2;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    10
       minus2 := minus1 + minus2;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    11
       minus1 := temp;
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
diff changeset
    12
       n := n - 1
75
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 73
diff changeset
    13
};
84
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 83
diff changeset
    14
write minus2 
75
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents: 73
diff changeset
    15