15 = 2*7+1 and 7 = 2*3+1 so 15 should be a safe prime. Am I missing something?
An (extra) safe prime number itself must be a prime number. Here, 15 is not a prime, so it is not (extra) safe prime
For case 8, x = 719;
which will lead to 44, not prime, the result should be false, but it's true now.
Am I right?
danteliujie, x = 719 does not lead to 44.
Why can't 71 be true?
Ups, 'maybe' 15 is not prime at all...
Oh sorry. I mean for Test #7
Test #5 x = 15;
15 = 2*7 + 1
7 = 2*3 + 1
3 is a prime number. therefore 7 is a safe prime. AND 15 is an extra safe prime. Or is there anything wrong with the equations above?
Lol. Forgot that 15 is not even a prime number.
isprime already exists!
This code would incorrectly identify x = 59 as an extra-safe prime (which it's not).
When x = 5 and x = 7, return false, is it right?
Yes, x = 5 and x = 7 are safe primes, but not "extra" safe primes because their corresponding values for p (2 and 3, respectively) are not safe primes.
This solution would incorrectly identify x = 71 as an extra-safe prime (which it's not).
Good catch, yurenchu. I'm adding 71 to the test suite.
6775 Solvers
1344 Solvers
Sum of diagonal of a square matrix
1333 Solvers
258 Solvers
252 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!