You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This solution is based on grade-school division. The way we detect recurring digits is if we have a cycle while doing our division. Let's take 1/3 for example:
1 | 3
Since our numerator (1) is smaller than our denominator (3), we shift the decimal place and multiply the numerator by 10.
10 | 3 = 0.
3 can fix 3 times in ten, so we subtract 3*3 from 10 and add 3 to the decimal places:
1 | 3 = 0.3
1 has already been seen, so we are in a cycle. Everything between the last occurrence of 1 and now will be repeated forever.