Project Euler 110 - Diophantine Reciprocals II

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

This is a harder version of Problem 108

Note: I am unhappy with my solution as I just completely brute forced the problem