Cody

Problem 44789. Big Integer Sqrt

Solution 3664133

Submitted on 15 Nov 2020
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   Fail
tic for i = 1 : 150 s = num2str([randi(9),randi([0, 9], 1, i)],-6); t = java.math.BigInteger(s); a = big_integer_sqrt(char(t.pow(2))); assert(isequal(a, char(s))); end toc

x = '400' y = '20' x = '640000' y = '800' x = '9412624' y = '3068' x = '4209673924' y = '64882' x = '107078818441' y = '327229' x = '9594338985729' y = '3097473' x = '2010301778559321' y = '44836389' x = '261290715337621225' y = '511166035' x = '63287631092204046025' y = '7955352355' x = '9770735231286861361401' y = '98847029451' x = '74412776072742056022544' y = '272787052612' x = '61401592061041208734725696' y = '7835916797736' x = '1944001712417258993724911401' y = '44090834789299' x = '325216585533413932322572877824' y = '570277638991232' x = '76880601412997165859011201939556' y = '8768158382066166' x = '289445063569578230321451147520609' y = '1.701308506913365e+16'

Assertion failed.

Suggested Problems

More from this Author17

Community Treasure Hunt

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

Start Hunting!