1 2; This Mathomatic input file contains the mathematical formula to 3; directly calculate the "n"th Fibonacci number. 4; The formula presented here is called Binet's formula, found at 5; http://en.wikipedia.org/wiki/Fibonacci_number 6; 7; The Fibonacci sequence is the endless integer sequence: 8; 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 ... 9; Any Fibonacci number is always the sum of the previous two Fibonacci numbers. 10; 11; Easy to understand info on the golden ratio can be found here: 12; http://www.mathsisfun.com/numbers/golden-ratio.html 13 14-1/phi=1-phi ; Derive the golden ratio (phi) from this quadratic polynomial. 150 ; show it is quadratic 16unfactor 17solve verifiable for phi ; The golden ratio will help us directly compute Fibonacci numbers. 18replace sign with -1 ; the golden ratio constant: 19fibonacci = ((phi^n) - ((1 - phi)^n))/(phi - (1 - phi)) ; Binet's Fibonacci formula. 20eliminate phi ; Completed direct Fibonacci formula: 21simplify ; Note that Mathomatic rationalizes the denominator here. 22for n 1 20 ; Display the first 20 Fibonacci numbers by plugging in values 1-20: 23; Note that this formula should work for any positive integer value of n. 24