Fibonacci sequence by recursive algorithm fail
04-20-2015, 06:42 PM (This post was last modified: 04-21-2015 02:27 PM by compsystems.)
Post: #1
 compsystems Senior Member Posts: 1,374 Joined: Dec 2013
Fibonacci sequence by recursive algorithm fail
The Fibonacci sequence by recursive algorithm fail in program type CAS, why?

http://en.wikipedia.org/wiki/Fibonacci_number

HPPrime CAS CODE
Code:
 #CAS     fibo(n):=     BEGIN         // versión 0.0.1 April 20             If n≤1 Then                      Return n;             Else                     Return (fibo(n-1)+fibo(n-2));             End;     END; #end

fibo(16) → "Error: Bad argument count"

HPPrime NUM CODE
Code:
EXPORT fibo(n) BEGIN   // versión 0.0.1 April 20     If n≤1 Then          Return n;     Else         Return (fibo(n-1)+fibo(n-2));     End; END;
fibo(16) → 987

TI68K CODE
Code:
 fibo(n) Func   Local tm   ©startTmr() → tm   If n≤1 Then       Return n   Else       Return fibo(n-1)+fibo(n-2)       ©checkTmr( sc )   EndIf EndFunc
fibo(16) → 987

other algorithms