Please Help me A twin primes is a pair of prime numbers such

Please Help me

A twin primes is a pair of prime numbers such that the difference between them is 2 (for example, 17 and 19). Write a computer program that finds all the twin primes between 10 and 500. The program displays the results in a two-column matrix in which each row is a twin prime. Do not use MATLAB\'s built-in function is prime.

Solution

excecutable code is:

%start the script

J=0; k=1;

For n=11:499

For i=2: n-1

If rem (n, i)   =0

J=j+1;

End

End

If==n-2

A (k) =n;

K=k+1;

End

J=0;

End

M=length (a);

Fprintf (‘the twin primes are:\ ’)

For p=1: m-1

If (a (p+1-a (p))==2

Fprintf (%i and %i\ ’, a (p), a (p+1))

End

End

The mat lab output

The twin primes are:

11 and 13

17 and 19

29 and 31

41 and 43

59 and 61

71 and 73

101 and 103

107 and 109

137 and 139

149 and 151

179 and 181

191 and 193

197 and 199

227 and 229

239 and 241

269 and 271

281 and 283

311 and 313

347 and 349

419 and 421

431 and 433

461 and 463

Please Help me A twin primes is a pair of prime numbers such that the difference between them is 2 (for example, 17 and 19). Write a computer program that finds
Please Help me A twin primes is a pair of prime numbers such that the difference between them is 2 (for example, 17 and 19). Write a computer program that finds

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site