Project Euler 45 - Triangle, pentagonal, and hexagonal
Project Euler 45 - Triangle, pentagonal, and hexagonal
Official link: https://projecteuler.net/problem=45
Thought Process
Thought Process
The same way I found the inverse for P(n) in Problem 44 I find the inverse for H(n), then I run through the Triangular numbers and the first number I find that is Pentagonal and Hexagonal I return it.
It would be faster to go through hexagonal numbers and check if it was triangle and pentagonal but my code runs in ~0.02 seconds so I wasn't too worried.
Interactive Code
Interactive Code
No interactive code for this one, code is given below