Project Euler - Problem Heegner

Official link: https://projecteuler.net/problem=heegner

Note: You won't be able to access the link until you unlock the problem

Grade feel: 10%

Thought Process

The case where n > 0 is not difficult, however notice that n can be less than 0. In this case we need to use the hyperbolic cosine function. 

Unfortunately the math module in python struggles to evaluate properly for larger numbers, so instead I first used a WolframAlpha Notebook to get the answer, after submitting the solutions and seeing some other answers, I used the decimal module to implement the algorithm with the required precision using the exponential form of cosh mentioned in the linked wikipedia article.

Interactive Code

Not applicable for this problem.