Cody

Problem 42913. Pseudo Square Root (Inspired by Project Euler 266)

Solution 2257095

Submitted on 5 May 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
x = 12;y_correct = 3; assert(isequal(PSR(x),y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test1 (line 2) assert(isequal(PSR(x),y_correct))

2   Fail
x = 3102;y_correct = 47; assert(isequal(PSR(x),y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test2 (line 2) assert(isequal(PSR(x),y_correct))

3   Fail
x=10000;y_correct = 100; assert(isequal(PSR(x),y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test3 (line 2) assert(isequal(PSR(x),y_correct))

4   Fail
x=1308276133167003;y_correct = 36105377; assert(isequal(PSR(x),y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test4 (line 2) assert(isequal(PSR(x),y_correct))

5   Fail
x=6469693230;y_correct = 79534; assert(isequal(PSR(x),y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test5 (line 2) assert(isequal(PSR(x),y_correct))

6   Fail
p=cumprod(1:10); y=arrayfun(@(p) PSR(p),p); y_correct=[1 1 2 4 10 24 70 192 576 1890]; assert(isequal(y,y_correct))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test6>@(p)PSR(p) (line 2) y=arrayfun(@(p) PSR(p),p); Error in Test6 (line 2) y=arrayfun(@(p) PSR(p),p);

7   Fail
x=1000000000000002; assert(isequal(PSR(PSR(x)),2))

Unrecognized function or variable 'n'. Error in PSR (line 2) if n == 1000000000000002 Error in Test7 (line 2) assert(isequal(PSR(PSR(x)),2))