Cody

Problem 1253. Infinite precision division

Solution 3044833

Submitted on 3 Oct 2020 by Augusto Mazzei
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
dividend = '122333444455555666666777777788888888999999999'; divisor = 42; quotient_correct = '2912701058465611111113756614021164023809523'; remainder_correct = 33; [quotient,remainder]=strdiv(dividend,divisor); while and(numel(quotient)>0,quotient(1)=='0') quotient=quotient(2:end); end assert(isequal([quotient_correct ' ' num2str(remainder_correct)],[quotient ' ' num2str(remainder)]))

q = [] dd = 122 c = 3 8 dd = 38 c = 5 dd = 5 c = 1 1 dd = 11 c = 2 9 dd = 29 c = 0 dd = 0 c = 2 dd = 2 c = 3 5 dd = 35 c = 1 9 dd = 19 c = 2 7 dd = 27 c = 2 3 dd = 23 c = 2 5 dd = 25 c = 4 dd = 4 c = 4 dd = 4 c = 4 dd = 4 c = 4 dd = 4 c = 4 dd = 4 c = 4 dd = 4 c = 5 dd = 5 c = 1 5 dd = 15 c = 3 1 dd = 31 c = 2 3 dd = 23 c = 2 7 dd = 27 c = 2 5 dd = 25 c = 5 dd = 5 c = 1 6 dd = 16 c = 0 dd = 0 c = 4 dd = 4 c = 6 dd = 6 c = 2 6 dd = 26 c = 1 6 dd = 16 c = 0 dd = 0 c = 1 5 dd = 15 c = 3 3 dd = 33 c = 3 dd = 3 c = 2 1 dd = 21 c = 9 dd = 9 c = 1 5 dd = 15 c = 3 3

Suggested Problems

More from this Author3

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!