Fibonacci sequence: Difference between revisions
Content deleted Content added
m →Recursive simple: syntax update |
m →State machine: syntax update |
||
Line 10,895: | Line 10,895: | ||
templates nthFibonacci |
templates nthFibonacci |
||
{ N: $, n0: 0, n1: 1 } -> # |
{ N: $, n0: 0, n1: 1 } -> # |
||
<{ N: <=0> }> |
when <{ N: <=0> }> do |
||
$.n0 ! |
$.n0 ! |
||
<{ N: <1..>}> |
when <{ N: <1..>}> do |
||
{ N: $.N - 1, n0: $.n1, n1: $.n0 + $.n1} -> # |
{ N: $.N - 1, n0: $.n1, n1: $.n0 + $.n1} -> # |
||
otherwise |
|||
<> |
|||
{ N: $.N + 1, n1: $.n0, n0: $.n1 - $.n0} -> # |
{ N: $.N + 1, n1: $.n0, n0: $.n1 - $.n0} -> # |
||
end nthFibonacci |
end nthFibonacci |