Well, that was an interesting adventure through recursion, brute force, wolfram alpha and big ints. spoiler for the math