The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
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
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

http://www.hpmuseum.org/forum/thread-316...=Fibonacci
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Fibonacci sequence by recursive algorithm fail - compsystems - 04-20-2015 06:42 PM



User(s) browsing this thread: 2 Guest(s)