Really difficult for me, to be honest, so I referenced someone else's answer. I think there should be a built-in function to handle such a basic math problem. I considered using the Euclidean algorithm and the method of successive subtraction, but ended up using the brute force method in the end.