Jump to content

Pi: Difference between revisions

54 bytes added ,  1 year ago
m
→‎{{header|D}}: updated syntaxhighlight lang=, etc...
m (→‎{{header|C sharp|C#}}: updated syntaxhighlight lang=, etc...)
m (→‎{{header|D}}: updated syntaxhighlight lang=, etc...)
Line 1,546:
=={{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.
<langsyntaxhighlight lang=d>import std.stdio, std.conv, std.string;
 
struct PiDigits {
Line 1,583:
foreach (d; PiDigits(100))
writeln(d);
}</langsyntaxhighlight>
{{out}}
Output:
<pre>314159265
358979323
Line 1,597:
534211706</pre>
===Alternative version===
<langsyntaxhighlight lang=d>import std.stdio, std.bigint;
 
void main() {
Line 1,629:
}
}
}</langsyntaxhighlight>
{{out}}
Output:
<pre>3.141592653589793238462643383279502884197169399375105820974944592307816
4062862089986280348253421170679821480865132823066470938446095505822317
Cookies help us deliver our services. By using our services, you agree to our use of cookies.