Fibonacci numbers in A++
Example for versions
A++ Interpreter
This example uses tail recursion.
(load "app/init.app")
(define fibonacci (lambda(f1 f2 n)
(if (equal n 0)
f1
(fibonacci f2 (+ f1 f2) (- n 1)))
))
(define main
(lambda(n)
(while (not (equal n 16))
(lambda()
(print (fibonacci 1 1 n))
(define n (+ n 1))))))
(main 0)
Comments
]]>blog comments powered by Disqus
]]>