Jump to content

Fibonacci n-step number sequences: Difference between revisions

Added Quackery.
m (→‎{{header|Phix}}: added syntax colouring the hard way)
(Added Quackery.)
Line 3,687:
nonanacci: 1 1 2 4 8 16 32 64 128 256 511 1021 2040 4076 8144
decanacci: 1 1 2 4 8 16 32 64 128 256 512 1023 2045 4088 8172</pre>
 
=={{header|Quackery}}==
 
<lang Quackery> [ 0 swap witheach + ] is sum ( [ --> n )
 
[ tuck size -
dup 0 < iff
[ split drop ]
else
[ dip [ dup size negate swap ]
times
[ over split
dup sum join join ]
nip ] ] is n-step ( n [ --> [ )
 
[ ' [ 1 1 ] n-step ] is fibonacci ( n --> [ )
 
[ ' [ 1 1 2 ] n-step ] is tribonacci ( n --> [ )
 
[ ' [ 1 1 2 4 ] n-step ] is tetranacci ( n --> [ )
 
[ ' [ 2 1 ] n-step ] is lucas ( n --> [ )
 
' [ fibonacci tribonacci tetranacci lucas ]
witheach
[ dup echo say ": " 10 swap do echo cr ]</lang>
 
{{out}}
 
<pre>fibonacci: [ 1 1 2 3 5 8 13 21 34 55 ]
tribonacci: [ 1 1 2 4 7 13 24 44 81 149 ]
tetranacci: [ 1 1 2 4 8 15 29 56 108 208 ]
lucas: [ 2 1 3 4 7 11 18 29 47 76 ]
</pre>
 
=={{header|Racket}}==
1,480

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.