Problem statement
For all odd prime number p greater than 3, there exists a positive integer n, such that p = 6n +/- 1 :
Check this formula for some given odd primes in a vector by computing n for each p.
Examples
  • p = 17 => n = 3;
  • p = 19 => n = 3;
  • p = [5, 7, 11, 13, 17, 19] => n = [1, 1, 2, 2, 3, 3];
  • p = [5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97];
=> n = [1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 7, 8, 9, 10, 10, 11, 12, 12, 13, 14, 15, 16];
Forbidden functions / expressions
  • regexp
  • assignin
  • str2num
  • echo
See also

Solution Stats

48 Solutions

36 Solvers

Last Solution submitted on Feb 12, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers36

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!