Cody

Problem 44385. Extra safe primes

Solution 1958347

Submitted on 3 Oct 2019
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 = 0; assert(isequal(isextrasafe(x),false))

2   Pass
x = 5; assert(isequal(isextrasafe(x),false))

3   Pass
x = 7; assert(isequal(isextrasafe(x),false))

4   Fail
x = 11; assert(isequal(isextrasafe(x),true))

Error using isprime (line 19) All entries of X must be nonnegative integers. Error in isextrasafe (line 5) if (isprime(floor(x-1)/2) && isprime(floor(floor(x-1)/2-1)/2) && isprime(floor((floor(floor(x-1)/2-1)/2)-1)/2)) Error in Test4 (line 2) assert(isequal(isextrasafe(x),true))

5   Pass
x = 15; assert(isequal(isextrasafe(x),false))

6   Pass
x = 23; assert(isequal(isextrasafe(x),true))

7   Pass
x = 71; assert(isequal(isextrasafe(x),false))

8   Pass
x = 719; assert(isequal(isextrasafe(x),true))

9   Fail
x = 2039; assert(isequal(isextrasafe(x),true))

Assertion failed.

10   Fail
x = 2040; assert(isequal(isextrasafe(x),false))

Error using isprime (line 19) All entries of X must be nonnegative integers. Error in isextrasafe (line 5) if (isprime(floor(x-1)/2) && isprime(floor(floor(x-1)/2-1)/2) && isprime(floor((floor(floor(x-1)/2-1)/2)-1)/2)) Error in Test10 (line 2) assert(isequal(isextrasafe(x),false))

11   Fail
x = 5807; assert(isequal(isextrasafe(x),true))

Assertion failed.