problem 16: once again, BigInteger saves the day