RosettaCodeData/Task/Twin-primes/00-TASK.txt
2023-07-01 13:44:08 -04:00

35 lines
1.2 KiB
Text

Twin primes are pairs of natural numbers &nbsp; (P<sub>1</sub> &nbsp;and&nbsp; P<sub>2</sub>) &nbsp; that satisfy the following:
::# &nbsp; &nbsp; P<sub>1</sub> &nbsp; and &nbsp; P<sub>2</sub> &nbsp; are primes
::# &nbsp; &nbsp; P<sub>1</sub> &nbsp;+&nbsp; '''2''' &nbsp; = &nbsp; P<sub>2</sub>
;Task:
Write a program that displays the number of <b>pairs of twin primes</b> that can be found <u>under</u> a user-specified number
<br>(P<sub>1</sub> < <i>user-specified number</i> & P<sub>2</sub> < <i>user-specified number</i>).
;Extension:
::# Find all twin prime pairs under 100000, 10000000 and 1000000000.
::# What is the time complexity of the program? Are there ways to reduce computation time?
;Examples:
<pre>
> Search Size: 100
> 8 twin prime pairs.
</pre>
<pre>
> Search Size: 1000
> 35 twin prime pairs.
</pre>
;Also see:
* &nbsp; The OEIS entry: [[oeis:A001097|A001097: Twin primes]].
* &nbsp; The OEIS entry: [[oeis:A167874|A167874: The number of distinct primes < 10^n which are members of twin-prime pairs]].
* &nbsp; The OEIS entry: [[oeis:A077800|A077800: List of twin primes {p, p+2}, with repetition]].
* &nbsp; The OEIS entry: [[oeis:A007508|A007508: Number of twin prime pairs below 10^n]].
<br><br>