Pi: Difference between revisions
Content added Content deleted
m (→{{header|C sharp|C#}}: updated syntaxhighlight lang=, etc...) |
m (→{{header|D}}: updated syntaxhighlight lang=, etc...) |
||
Line 1,546: | Line 1,546: | ||
=={{header|D}}== |
=={{header|D}}== |
||
This modified [[wp:Spigot_algorithm|Spigot algorithm]] does not continue infinitely, because its required memory grow as the number of digits need to print. |
This modified [[wp:Spigot_algorithm|Spigot algorithm]] does not continue infinitely, because its required memory grow as the number of digits need to print. |
||
< |
<syntaxhighlight lang=d>import std.stdio, std.conv, std.string; |
||
struct PiDigits { |
struct PiDigits { |
||
Line 1,583: | Line 1,583: | ||
foreach (d; PiDigits(100)) |
foreach (d; PiDigits(100)) |
||
writeln(d); |
writeln(d); |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
|||
Output: |
|||
<pre>314159265 |
<pre>314159265 |
||
358979323 |
358979323 |
||
Line 1,597: | Line 1,597: | ||
534211706</pre> |
534211706</pre> |
||
===Alternative version=== |
===Alternative version=== |
||
< |
<syntaxhighlight lang=d>import std.stdio, std.bigint; |
||
void main() { |
void main() { |
||
Line 1,629: | Line 1,629: | ||
} |
} |
||
} |
} |
||
}</ |
}</syntaxhighlight> |
||
{{out}} |
|||
Output: |
|||
<pre>3.141592653589793238462643383279502884197169399375105820974944592307816 |
<pre>3.141592653589793238462643383279502884197169399375105820974944592307816 |
||
4062862089986280348253421170679821480865132823066470938446095505822317 |
4062862089986280348253421170679821480865132823066470938446095505822317 |