Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27348

Help with Algorithms - Chudnovsky (Pi)

$
0
0
Since everyone's been so helpful around here, I thought I'd ask this, I've been interested in Pi for a while, and I've always wanted to make a program which calculates Pi. And I found, that the best formula/algorithm to calculate Pi is the Chudnovsky algorithm, http://en.wikipedia.org/wiki/Chudnovsky_algorithm

This is what I got so far:

Private Function asd(ByVal stopAt As Integer)
Dim pi As BigNum
For k As Integer = 1 To stopAt
pi += (BigMath.Pow(-1.0, k) * BigMath.Factorial(6.0 * k) * (13591409.0 + (545140134.0 * k))) / (BigMath.Factorial(3.0 * k) * BigMath.Pow(BigMath.Factorial(k), 3.0) * BigMath.Pow(640320.0, 3.0 * k + 3.0 / 2.0))
Next
End Function


Where I use k in a For statement.
The problem I'm having is that I don't get any value (and, no, I'm not stupid, I removed the return ;) )

I'm using the W3b Sine library for my math.

Viewing all articles
Browse latest Browse all 27348

Trending Articles