progs/fib.while
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Sun, 03 Nov 2013 00:41:24 +0000
changeset 178 d36363d648e3
parent 147 4725bba8ef26
child 182 9ce2414e470e
permissions -rw-r--r--
added

/* Fibonnacci sequence 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