Problem statement
The twin prime couples (p,p') are the ones such that p' = p + 2.
For a given integer n > 1, list the twin prime couples less or equal to n.
Present your result in a m x 2 matrix, where m is the number of twin couples.
Examples
  • n = 10 => p = [3, 5; 5, 7];
  • n = 20 => p = [3, 5; 5, 7; 11, 13; 17 19];
  • n = 100 => p = [3, 5; 5, 7; 11, 13; 17 19; 29, 31; 41, 43; 59, 61; 71, 73];
Forbidden functions / expressions
  • regexp
  • assignin
  • str2num
  • echo
See also

Solution Stats

49 Solutions

33 Solvers

Last Solution submitted on Feb 06, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...

Problem Recent Solvers33

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!