Problem 46060. Identify primorial primes
Cody Problems 46054 and 46057 deal with the primorial
#, which is the product of all primes up to and including the nth prime
. The primorials corresponding to n = 1 through 5 are 2, 6, 30, 210, and 2310. Primorial primes are prime numbers that are either one smaller or one larger than a primorial. Examples include 3, 5, 7, 29, 31, 211, 2309, and 2311.
Write a function to identify primorial primes and their associated primorials. Given an input x, return a variable y with one of the following values:
y = 1 if x is a primorial prime
y = 0 if x is prime but not a primorial prime
y = -Inf if x is composite or 1
Also return a variable p that is the associated primorial in the first case and NaN in the other two cases.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers18
Suggested Problems
-
Return a list sorted by number of occurrences
2840 Solvers
-
Find best placement for ordered dominoes (harder)
332 Solvers
-
Create Volcano (or Atoll) martix. It is an extension of Bullseye matrix problem.
152 Solvers
-
Temperature Conversion Utility
46 Solvers
-
Find the sides of an isosceles triangle when given its area and height from its base to apex
2070 Solvers
More from this Author314
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!