Post Reply 
Fibonacci sequence by recursive algorithm fail
04-22-2015, 12:41 PM
Post: #14
RE: Fibonacci sequence by recursive algorithm fail
Quite right.

Code:

// ======================================
//  Fibonacci Sequence Generator
//
//  Input: length of sequence
//  Output: Fibonacci List
//
// ======================================

EXPORT fibo(n)
BEGIN

  local j:=3;  
  HDigits:=0;
  L1:={0};
  
  if n==0 then return L1; end; 
  if n==1 then return concat(L1,1); end;

  print();
  L1:={0,1};
  repeat    
    L1:=concat(L1,L1(j-1)+L1(j-2));
    j:=j+1;
  until j==n+1;
  print(L1);
  
END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Fibonacci sequence by recursive algorithm fail - DrD - 04-22-2015 12:41 PM



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