深夜の暇つぶし
using System;
using System.Threading.Tasks;
using System.Numerics;//参照の追加がいったような
namespace ConsoleApplication1{
class Program {
private static void body(int idx) {
BigInteger n = new BigInteger(idx);
calc(n);
}
public static void calc(BigInteger n) {
while (true) {
if (n.CompareTo(1) == 0) { break; }
n = collatz(n);
}
}

public static BigInteger collatz(BigInteger n) {
if (BigInteger.Remainder(n, new BigInteger(2)).CompareTo(0) == 0)
return BigInteger.Divide(n, new BigInteger(2));
else
return BigInteger.Add(BigInteger.Multiply(n, new BigInteger(3)), new BigInteger(1));
}

static void Main(string[] args) {
DateTime s = DateTime.Now;
Parallel.For(1, 1000000, body); // 1から999999まで
DateTime e = DateTime.Now;
System.Console.WriteLine((e.Subtract(s).TotalMilliseconds) / 1000.0 + "secs");
} }}
何十秒で結果が出ます?