Problem 60967. List primes which are the sum of two consecutive lower primes plus minus one
Problem statement
Some prime numbers can be written as the sum of two consecutive lower primes plus / minus one :
Like this for example, 7 = 3 + 5 - 1, and 11 = 5 + 7 - 1.
In a vector, list such prime numbers lower than a given -input- positive integer m.
Examples
- m = 50 => p = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43];
- m = 100 => p = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 53, 59, 61, 67, 79, 83, 89];
- m = 200 => p = [7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 53, 59, 61, 67, 79, 83, 89, 101, 113, 127, 131, 151, 163, 173, 197, 199];
Fobidden functions
- regexp
- str2num
- assignin
- echo
See also
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers11
Suggested Problems
More from this Author42
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!