Math::NumSeq::TwinPrimes -- twin primes
use Math::NumSeq::TwinPrimes; my $seq = Math::NumSeq::TwinPrimes->new; my ($i, $value) = $seq->next;
The twin primes 3, 5, 11, 19, 29, etc, where both P and P+2 are primes.
See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.
$seq = Math::NumSeq::TwinPrimes->new ()
$seq = Math::NumSeq::TwinPrimes->new (pairs => 'second')
Create and return a new sequence object. The optional
pairsparameter (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
$valueis a twin prime etc. This follows any
pairsparameter, so for example "second" means
pred()returns true only when
$valueis the second of a pair, ie.
$value-2is also a prime.
Copyright 2010, 2011 Kevin Ryde
Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.