progs/fib.while
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 11 Nov 2013 00:34:14 +0000
changeset 182 9ce2414e470e
parent 178 d36363d648e3
child 207 f824e1331fc6
permissions -rw-r--r--
added

/* Fibonnacci numbers implemented in 
   the WHILE language */
   
write "Input a number ";
read n;
x := 0;   // start values
y := 1;
while n > 0 do {
  temp := y;
  y := x + y;
  x := temp;
  n := n - 1  // decrement counter
};
write "Result ";
write y