Problem 60971. List the twin prime couples
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
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers13
Suggested Problems
-
13 Solvers
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!