Project Euler 33 - Digit cancelling fractions
Project Euler 33 - Digit cancelling fractions
Official link: https://projecteuler.net/problem=33
Thought Process
Thought Process
I simply do a double nested loop through 2 variables x, y where x goes from 10 to 100 and y goes from x+1 to 100, this is to ensure that x/y < 1.
I check quickly that x and y are not divisible by 10 to remove the trivial cases
Initialise 2 variables v1 = str(x), v2 = str(y), and I check if these strings have matching integers, if they do I create x' and y' which has this digit removed and I check if x/y = x'/y' and if it is I stored it.
Make sure to divide the denominator by the gcd(denominator, numerator) at the end so it's in it's most simplified form
Interactive Code
Interactive Code
No interactive code for this problem, my code is given below