/* the Fibonacci extension */
/* see the effect of setting m and n to consecutive Fibonacci numbers */
m = 55;
n = 21;
?sqrt;
writeln(sqrt(5));
alpha is (1 + sqrt(5))/2;
beta is (1 - sqrt(5))/2;
writeln(alpha);
writeln(beta);
B is (alpha - 1) / (alpha - beta);
A is (1 - beta) / (alpha - beta);
?pow;
writeln(pow(alpha, 2));
/* check that sequence pow(alpha,k) satisfies the Fibonacci recurrence:
pa1 is pow(alpha,1);
pa2 is pow(alpha,2);
pa3 is pow(alpha,3);
pa4 is pow(alpha,4);
pa12 is pa1+pa2;
pa23 is pa2+pa3;
pa34 is pa3+pa4;
*/
fibk is int(A*pow(alpha, k)+B*pow(beta, k));
fibkplus1 is int(A*pow(alpha, k+1)+B*pow(beta, k+1));
?fibk;
m = 75025;
n = 46368;
m is fibkplus1; n is fibk;
k = 4;
k = 20;
k = 23;
k = 25;