and 1 contributors

NAME

Math::NumSeq::TwinPrimes -- twin primes

SYNOPSIS

use Math::NumSeq::TwinPrimes;
my \$seq = Math::NumSeq::TwinPrimes->new;
my (\$i, \$value) = \$seq->next;

DESCRIPTION

The twin primes 3, 5, 11, 19, 29, etc, where both P and P+2 are primes.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

\$seq = Math::NumSeq::TwinPrimes->new ()
\$seq = Math::NumSeq::TwinPrimes->new (pairs => 'second')

Create and return a new sequence object. The optional pairs parameter (a string) controls which of each twin-prime pair of values is returned

"first"      the first of each pair, 3,5,11,17 etc
"second"     the second of each pair 5,7,13,19 etc
"both"       both values 3,5,7,11,13,17,19 etc
"average"    the average of the pair, 4,6,12,8 etc

"both" is without repetition, so for example 5 belongs to the pair 3,5 and 5,7, but is returned in the sequence just once.

\$bool = \$seq->pred(\$value)

Return true if \$value is a twin prime of the given pairs type. For example with "second" pred() returns true when \$value is the second of a pair, ie. \$value-2 is also a prime.

\$i = \$seq->value_to_i_estimate(\$value)

Return an estimate of the i corresponding to \$value. Currently this is the asymptotic by Brun

value
i ~= 2 * C * --------------
(log(value))^2

with Hardy and Littlewood's conjectured twin-prime constant C=0.66016. In practice it's quite close, being too small by a factor between 0.75 and 0.85 in the small to medium size integers this module might calculate.