Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NB. Generates y Fibonacci numbers starting with 0 1.
- NB. If the y argument is boxed, generates
- NB. Fibonacci numbers up to the given number.
- NB. Tribonacci numbers (and so on) can be generated
- NB. as follows: 0 0 1x fibonacci 1e3.
- fibonacci =: 3 : 0 "0 1 0
- 0x 1x fibonacci y
- :
- (,a)^:((>y)>#`(a=.+/@((-#x)&{.))@.(L.y))^:_ x
- )
- NB. Examples:
- NB. Generate the first 20 Fibonacci numbers:
- fibonacci 20
- NB. Generate the first 20 Tribonacci numbers:
- 0 0 1x fibonacci 20
- NB. Generate the Fibonacci numbers up to 1e8:
- fibonacci <1e8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement