Problem 0413 (too slow)
Problem 0413 with long instead of BigInteger