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.


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

26.08% Correct | 73.92% Incorrect
Last solution submitted on Nov 16, 2018

Problem Comments

Solution Comments

Recent Solvers393

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!