Mar 20, 2017 at 5:28pm UTC
Value will be stored in a vector but answer should stop at repeating number.
ex 988 / 56
Answer 17.6428571429
But I want Answer to be 17.642857
Mar 20, 2017 at 6:00pm UTC
First get the integer quotient (17 in this example) and the remainder (36). Then start a loop:
//digit 1:
r = 360, r/d = 6 , r%d = 24
//digit 2:
r = 240, r/d = 4 , r%d = 16
//digit 3:
r = 160, r/d = 2 , r%d = 48
//digit 4:
r = 480, r/d = 8 , r%d = 32
//digit 5:
r = 320, r/d = 5 , r%d = 40
//digit 6:
r = 400, r/d = 7 , r%d = 8
//digit 7:
r = 80, r/d = 1 , r%d = 24
//digit 8:
r = 240, r/d = 4 , r%d = 16
At this point r for digit 8 is equal to r for digit 2, so you know that this is where the repeating decimal starts. So the number up to the first repeating decimal is
17.6428571