Prime pairs that yield primes | Matlab Examples

Matlab Tutorials | Examples

Practice 5:

Prime pairs that yield primes

A prime number is a number that can be divided without remainder only to 1 and itself. You can find out that a number p is prime by dividing it by all numbers between

2 and p, and verifying that the remainders in all such divisions are non-zero.

Consider the pairs of successive prime numbers, such as (2, 3), (3, 5), (5, 7), (7, 11), (11, 13), (13, 17), etc. Write a program that finds the first ten successive prime pairs (p, q), such that pq+p+q is also a prime number.

While writing this program, you are expected NOT to use vectors (arrays) or any MATLAB functions that automatically give you prime numbers, such as primes(), isprime(), etc.

Solution:

 

Leave a Reply

Your email address will not be published. Required fields are marked *