Cody

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

Solution 1705901

Submitted on 11 Jan 2019 by HH
• Size: 9
• This is the leading solution.
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
x = 12;y_correct = 3; assert(isequal(PSR(x),y_correct))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint1 (line 2) In solutionTest (line 3)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint3 (line 2) In solutionTest (line 7)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint4 (line 2) In solutionTest (line 9)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint5 (line 2) In solutionTest (line 11)]

6   Pass
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))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint6>@(p)PSR(p) In ScoringEngineTestPoint6 (line 2) In solutionTest (line 13)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint7 (line 2) In solutionTest (line 15)] [Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In PSR (line 2) In ScoringEngineTestPoint7 (line 2) In solutionTest (line 15)]