Extra safe primes - MATLAB Cody - MATLAB Central

Problem 44385. Extra safe primes

Difficulty:Rate

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

22.45% Correct | 77.55% Incorrect
Last Solution submitted on Mar 05, 2025

Problem Comments

Solution Comments

Show comments

Group

Number theory Image
Number theory
  • 44 Problems
  • 21 Finishers

Problem Recent Solvers741

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page