Problem statement
For all odd prime number p, there exists a positive integer n, such that p = 4n +/- 1 :
Check this formula for some given odd primes in a vector by computing n for each p.
Examples
  • p = 17 => n = 4;
  • p = 19 => n = 5;
  • p = [3, 5, 7, 11, 13, 17, 19] => n = [1, 1, 2, 3, 3, 4, 5];
  • p = [3, 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, 3, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 15, 15, 17, 18, 18, 20, 21, 22, 24];
Forbidden functions / expressions
  • regexp
  • assignin
  • str2num
  • echo
See also

Solution Stats

52 Solutions

39 Solvers

Last Solution submitted on Feb 06, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers39

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!