Sync
This commit is contained in:
parent
6f050a029e
commit
776bba907c
3887 changed files with 59894 additions and 7280 deletions
|
|
@ -1,10 +1,9 @@
|
|||
import std.stdio, std.random, std.math, std.algorithm, std.range;
|
||||
|
||||
bool isIn(int){ return hypot(uniform(0,1.0), uniform(0,1.0)) <= 1; }
|
||||
|
||||
double pi(in int n) { return 4.0 * count!isIn(iota(n)) / n; }
|
||||
enum isIn = (int) => hypot(uniform(0, 1.0), uniform(0, 1.0)) <= 1;
|
||||
enum pi = (in int n) => 4.0 * n.iota.count!isIn / n;
|
||||
|
||||
void main() {
|
||||
foreach (p; 1 .. 8)
|
||||
foreach (immutable p; 1 .. 8)
|
||||
writefln("%10s: %07f", 10 ^^ p, pi(10 ^^ p));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue