Toms kleine Welt
Sonntag, 22. Mai 2011
Leibniz-Reihe in Groovy
Hier nur zum Spaß eine Groovy-Funktion, die die
Leibniz-Reihe
berechnet:
def lr = {n->
n.sum { k ->
((-1)**k) / (2*k+1)
} * 4
}
assert lr(0..100000) == Math.PI
Startseite
Abonnieren
Posts (Atom)