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

6th Nov 2020, 4:20 AM
Smiley[Offline]
5 Answers
+ 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
6th Nov 2020, 4:32 AM
Arsenic
Arsenic - avatar
+ 4
from __future__ import division __truediv__(self, other)Implements true division. Note that this only works when from __future__ import division is in effect.
6th Nov 2020, 4:27 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
ChaoticDawg Sir but if I change while to if it works perfectly
6th Nov 2020, 4:28 AM
Smiley[Offline]
+ 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
6th Nov 2020, 8:00 AM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar
+ 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
6th Nov 2020, 8:08 AM
Smiley[Offline]