Fibonacci sequence: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add Cowgol) |
Not a robot (talk | contribs) (Add MAD) |
||
Line 6,579: | Line 6,579: | ||
define(`loop',`ifelse($1,$2,,`$3($1) loop(incr($1),$2,`$3')')')dnl |
define(`loop',`ifelse($1,$2,,`$3($1) loop(incr($1),$2,`$3')')')dnl |
||
loop(0,15,`fibo')</lang> |
loop(0,15,`fibo')</lang> |
||
=={{header|MAD}}== |
|||
<lang MAD> NORMAL MODE IS INTEGER |
|||
INTERNAL FUNCTION(N) |
|||
ENTRY TO FIB. |
|||
A = 0 |
|||
B = 1 |
|||
THROUGH LOOP, FOR N=N, -1, N.E.0 |
|||
C = A + B |
|||
A = B |
|||
LOOP B = C |
|||
FUNCTION RETURN A |
|||
END OF FUNCTION |
|||
THROUGH SHOW, FOR I=0, 1, I.GE.20 |
|||
SHOW PRINT FORMAT FNUM, I, FIB.(I) |
|||
VECTOR VALUES FNUM = $4HFIB(,I2,4H) = ,I4*$ |
|||
END OF PROGRAM </lang> |
|||
{{out}} |
|||
<pre style='height: 50ex;'>FIB( 0) = 0 |
|||
FIB( 1) = 1 |
|||
FIB( 2) = 1 |
|||
FIB( 3) = 2 |
|||
FIB( 4) = 3 |
|||
FIB( 5) = 5 |
|||
FIB( 6) = 8 |
|||
FIB( 7) = 13 |
|||
FIB( 8) = 21 |
|||
FIB( 9) = 34 |
|||
FIB(10) = 55 |
|||
FIB(11) = 89 |
|||
FIB(12) = 144 |
|||
FIB(13) = 233 |
|||
FIB(14) = 377 |
|||
FIB(15) = 610 |
|||
FIB(16) = 987 |
|||
FIB(17) = 1597 |
|||
FIB(18) = 2584 |
|||
FIB(19) = 4181</pre> |
|||
=={{header|Maple}}== |
=={{header|Maple}}== |