0
I wanted to create a program for simplification of fraction in python [solved]
i wanted it to convert 4/8 to 1/2 but it is showing me no output pls help me my code https://code.sololearn.com/c0yXjkGP9eEE
5 Respostas
+ 9
Smiley (Offline) you are not updating the values of self.num and other.num in the loop which is resulting in an infinite loop.
Here's the fix👇
https://code.sololearn.com/c8q6ddjKY9RP/?ref=app
+ 4
from __future__ import division
__truediv__(self, other)Implements true division. Note that this only works when from __future__ import division is in effect.
+ 1
ChaoticDawg
Sir but if I change while to if it works perfectly
+ 1
There is a lot more to be fixed. 3/6 results in reference error.
And if you fix that it will not simplify because it only works for powers of 2
Hint: greatest common divider
+ 1
Benjamin Jürgens
Yup I know I was just trying it first with 2
Now it's easy I would now just change 2 with a list of all prime numbers