Problem 44385. Extra safe primes
Did you know that the number 5 is the first safe prime? A safe prime is a prime number that can be expressed as 2p+1, where p is also a prime.
To celebrate Cody's Five-Year Anniversary, write a function to determine if a positive integer n is a safe prime in which the prime p (such that n=2p+1) is also a safe prime.
Examples
isextrasafe(5) = false % because 5=2*2+1 and 2 is not a safe prime isextrasafe(23) = true % because 23=2*11+1 and 11 is also a safe prime (11=2*5+1)
Solution Stats
Problem Comments
-
4 Comments
Show
1 older comment
Peng Liu
on 16 Oct 2017
An (extra) safe prime number itself must be a prime number. Here, 15 is not a prime, so it is not (extra) safe prime
danteliujie
on 27 Feb 2019
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?
Matthew Eicholtz
on 28 Feb 2019
danteliujie, x = 719 does not lead to 44.
Solution Comments
Show commentsGroup

Date & Time I
- 14 Problems
- 42 Finishers
- Find the nearest prime number
- Extra safe primes
- Prime factor digits
- Twin Primes
- Twins in a Window
- The Goldbach Conjecture
- The Goldbach Conjecture, Part 2
- Goldbach's marginal conjecture - Write integer as sum of three primes
- Sophie Germain prime
- Mersenne Primes vs. All Primes
- Circular Primes (based on Project Euler, problem 35)
- Numbers spiral diagonals (Part 2)
- Pernicious Anniversary Problem
- Prime Ladders
Problem Recent Solvers741
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!