Take a look at this page and it's BigNumber
class.
The first thing to note is that we can't use any of the primitive types in C#: they just don't have enough precision (the double type, for example, only has 15 significant digits, and we want to calculate, say, 10000). We need a large precision number library, but there's nothing like that in the .NET Framework, and so the first thing we'll have to do is write a BigNumber class.
That page also provides an example usage for calculating pi out to 1000 decimal places, so it should be fairly trivial to run it for 16000.
Running it for 16000 digits takes me about a second and a half, for 160,000 digits takes me a bit over 2 minutes.
Here's my PrintAsTable()
function, which the linked post leaves as an exercise for the reader:
public string PrintAsTable() {
var data = Print();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < data.Length; i++)
{
if (data[i] == '.') sb.AppendLine(".");
else if ((i -1) % 50 == 0) sb.AppendLine(data[i].ToString());
else if ((i -1) % 10 == 0) {sb.Append(data[i].ToString()); sb.Append(" ");}
else sb.Append(data[i].ToString());
}
return sb.ToString();
}