Fibonacci sequence: Difference between revisions
Content added Content deleted
m (→{{header|PL/SQL}}: Simplified the code (using CASE statement) and added error handling.) |
PatGarrett (talk | contribs) (→{{header|ALGOL 60}}: Section added) |
||
Line 501: | Line 501: | ||
} |
} |
||
</lang> |
</lang> |
||
=={{header|ALGOL 60}}== |
|||
{{works with|A60}} |
|||
<lang algol60>begin |
|||
comment Fibonacci sequence; |
|||
integer procedure fibonacci(n); value n; integer n; |
|||
begin |
|||
integer i, fn, fn1, fn2; |
|||
fn2 := 1; |
|||
fn1 := 0; |
|||
fn := 0; |
|||
for i := 1 step 1 until n do begin |
|||
fn := fn1 + fn2; |
|||
fn2 := fn1; |
|||
fn1 := fn |
|||
end; |
|||
fibonacci := fn |
|||
end fibonacci; |
|||
integer i; |
|||
for i := 0 step 1 until 20 do outinteger(1,fibonacci(i)) |
|||
end </lang> |
|||
{{out}} |
|||
<pre> |
|||
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 |
|||
</pre> |
|||
=={{header|ALGOL 68}}== |
=={{header|ALGOL 68}}== |