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

116 Solutions

55 Solvers

Last Solution submitted on Feb 06, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers55

Suggested Problems

More from this Author42

Community Treasure Hunt

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

Start Hunting!