How to resolve the algorithm Fibonacci n-step number sequences step by step in the Ol programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Fibonacci n-step number sequences step by step in the Ol programming language
Table of Contents
Problem Statement
These number series are an expansion of the ordinary Fibonacci sequence where: For small values of
n
{\displaystyle n}
, Greek numeric prefixes are sometimes used to individually name each series. Allied sequences can be generated where the initial values are changed:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Fibonacci n-step number sequences step by step in the Ol programming language
Source code in the ol programming language
(define (n-fib-iterator ll)
(cons (car ll)
(lambda ()
(n-fib-iterator (append (cdr ll) (list (fold + 0 ll)))))))
(print "2, fibonacci : " (ltake (n-fib-iterator '(1 1)) 15))
(print "3, tribonacci: " (ltake (n-fib-iterator '(1 1 2)) 15))
(print "4, tetranacci: " (ltake (n-fib-iterator '(1 1 2 4)) 15))
(print "5, pentanacci: " (ltake (n-fib-iterator '(1 1 2 4 8)) 15))
(print "2, lucas : " (ltake (n-fib-iterator '(2 1)) 15))
; ==>
2, fibonacci : (1 1 2 3 5 8 13 21 34 55 89 144 233 377 610)
3, tribonacci: (1 1 2 4 7 13 24 44 81 149 274 504 927 1705 3136)
4, tetranacci: (1 1 2 4 8 15 29 56 108 208 401 773 1490 2872 5536)
5, pentanacci: (1 1 2 4 8 16 31 61 120 236 464 912 1793 3525 6930)
2, lucas : (2 1 3 4 7 11 18 29 47 76 123 199 322 521 843)
You may also check:How to resolve the algorithm Multiplication tables step by step in the hexiscript programming language
You may also check:How to resolve the algorithm Partial function application step by step in the CoffeeScript programming language
You may also check:How to resolve the algorithm User input/Text step by step in the RPL programming language
You may also check:How to resolve the algorithm Hello world/Standard error step by step in the Metafont programming language
You may also check:How to resolve the algorithm Thue-Morse step by step in the BBC BASIC programming language