public long GetAnswerTo70() { const int limit = 10000000; var sieve = new CoprimeSieve(limit); return Sequences.Range(2, limit).MinByWithPostCondition( n => (double)n / sieve.Phi(n), n => IsPermutation(n, sieve.Phi(n))); }
public long GetAnswerTo72() { const int limit = 1000000; var sieve = new CoprimeSieve(limit); return Sequences.Range(2, limit).Sum(n => sieve.Phi(n)); }
public long GetAnswerTo69() { const int limit = 1000000; var sieve = new CoprimeSieve(limit); return Sequences.Range(2, limit).AsParallel().MaxBy(n => (double)n / sieve.Phi(n)); }