Twin Primes - MATLAB Cody - MATLAB Central

Problem 3016. Twin Primes

Difficulty:Rate

Twin primes are pairs of primes that are immediately next to each other (difference of two). The lesser of twin primes are 3, 5, 11, 17, 29, ... ( ref. ). The greater of twin primes are 5, 7, 13, 19, 31, ... ( ref. ). Therefore, the first five twin primes are [3,5] [5,7] [11,13] [17,19] [29,31].

For a given index range n, return the twin primes corresponding to that range as a two-row column array.

Solution Stats

50.0% Correct | 50.0% Incorrect
Last Solution submitted on Feb 10, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
7
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Group

The Prime Directive Image
The Prime Directive
  • 14 Problems
  • 37 Finishers

Problem Recent Solvers86

Problem Tags

Community Treasure Hunt

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

Start Hunting!
Go to top of page