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.
Find the sum of the elements in the "second" diagonal
Create a square matrix of multiples
Basics: 'Find the eigenvalues of given matrix
01 - Scalar variables
String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values
Assign matrix elements to separate variables
Check if vertices form a rectangle
Find the nearest prime number
List of built-in demo images
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office