Cody

Problem 44789. Big Integer Sqrt

Solution 3664143

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

y = '42' y = '226' y = '1856' y = '13515' y = '829373' y = '4194878' y = '16060506' y = '752764941' y = '2662860812' y = '93473905833' y = '527345937935' y = '8373163203142' y = '85340223495686' y = '136224199908208' y = '2018392668926677' y = '41710897428594904'

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!