#Python
#Advantages:
Go as Precise as you want or can handle
Find out the repetitiveness from the quotient
Fast
Late to the party but here you go:
def ManualDivision(Dividend, Divisor, acQPrecision, BreakOnRepetitive):
Repetitive = False
RepetitiveIndex = 0
bcQComplete = False
acQComplete = False
bcQ = '' #before comma Quotient
acQ = '' #after comma Quotient
history = []
a = 0
b = 0
while (not bcQComplete or not acQComplete):
if not bcQComplete:
for digit in map(int, str(Dividend)):
a = int(str(a) + str(digit))
if a in history:
if not Repetitive:
Repetitive = True
RepetitiveIndex = len(history) - len(bcQ)
if BreakOnRepetitive:
break
else:
history.append(a)
if a < Divisor:
b = 0
bcQ += '0'
else:
pQ = 0
result = a - Divisor
while result >= 1:
pQ += 1
result -= Divisor
b = pQ * Divisor
bcQ += str(pQ)
a -= b
bcQComplete = True
if not acQComplete:
acQPrecision -= 1
if acQPrecision <= 0:
acQComplete = True
a = int(str(a) + str('0'))
if a in history:
if not Repetitive:
Repetitive = True
RepetitiveIndex = len(history) - len(bcQ)
if BreakOnRepetitive:
break
else:
history.append(a)
if a < Divisor:
b = 0
acQ += '0'
else:
pQ = 0
result = a - Divisor
while result >= 1:
pQ += 1
result -= Divisor
b = pQ * Divisor
acQ += str(pQ)
a-=b
return '{0}.{1} \nRepetitive: {2} from position {3} acQ \nHistory:{4}'.format(bcQ, acQ, Repetitive, RepetitiveIndex, history)
#Result Quotient = ManualDivision(91,256,100,False) #Dividend = 91, Divisor = 256, precision= 100, breakonprecision=False print(Quotient)
00.3554687499999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
Repetitive: True from position 9 acQ
History:[9, 91, 910, 1420, 1400, 1200, 1760, 2240, 1920, 1280, 2560]