I recently started to learn Python. On one of the online courses I came across the following problem(see picture)
The actual decomposition fraction is sufficiently detailed and clearly described in Wikipedia (https://ru.wikipedia.org/wiki/Непрерывная_дробь)
I wrote the following program:
While trying to test the example from the job, the required coefficients (7,1,29) are displayed correctly, but the loop becomes infinite and for some reason does not stop, despite the fact that at some point b becomes zero. I, frankly, broke his head in an attempt to understand why this is happening.. maybe someone can explain to me, what am I missing?
I wrote a program using divmod, but, similarly, although the equality of b to zero, the loop continues( and the list of coefficients instead of 29 turns 30..
In General, I would be very grateful if someone will help with advice a beginner)