Fibonacci sequence: Difference between revisions

Content deleted Content added
+D
→‎{{header|D}}: Fixed English
Line 39: Line 39:


=={{header|D}}==
=={{header|D}}==
Here are four version of Fibonacci Number generating functions.<br>
Here are four versions of Fibonacci Number generating functions.<br>
''FibD'' has an argument limit of magnitude 82 due to floating point precision, the others have a limit of 92 due to overflow (long).<br>
''FibD'' has an argument limit of magnitude 82 due to floating point precision, the others have a limit of 92 due to overflow (long).<br>
The traditional recursive version is inefficient. It is optimized by supplying a static storage to store intermediate results.<br>
The traditional recursive version is inefficient. It is optimized by supplying a static storage to store intermediate results.<br>
All four functions have extended to deal with negative argument.
All four functions have support for negative arguments.
<d>module fibonacci ;
<d>module fibonacci ;
import std.stdio ;
import std.stdio ;
Line 96: Line 96:
I : 99194853094755497 <- 61305790721611591 + 37889062373143906
I : 99194853094755497 <- 61305790721611591 + 37889062373143906
O : 99194853094755497 <- 61305790721611591 + 37889062373143906</pre>
O : 99194853094755497 <- 61305790721611591 + 37889062373143906</pre>

=={{header|Forth}}==
=={{header|Forth}}==
: fib ( n -- fib )
: fib ( n -- fib )