P(n) is an increasing function, therefore we want P(k) and P(j) to be as close to each other as possible to minimise their absolute difference.
I made 2 functions
Take's an integer x and tests if this number is a pentagonal number by taking the inverse, see below to see how to derive the inverse function
initialise k = 1, start a while loop, then a for loop goes through j from 1 to k, it will then test if P(k) - P(j) and P(k) + P(j) are both pentagonal, as soon as I find one I know it will be the minimum solution
No interactive code for this one, code is given below