1Math::NumSeq::TwinPrimeUss(e3r)Contributed Perl DocumentMaattiho:n:NumSeq::TwinPrimes(3)
2
3
4
6 Math::NumSeq::TwinPrimes -- twin primes
7
9 use Math::NumSeq::TwinPrimes;
10 my $seq = Math::NumSeq::TwinPrimes->new;
11 my ($i, $value) = $seq->next;
12
14 The twin primes 3, 5, 11, 19, 29, etc, where both P and P+2 are primes.
15
17 See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence
18 classes.
19
20 "$seq = Math::NumSeq::TwinPrimes->new ()"
21 "$seq = Math::NumSeq::TwinPrimes->new (pairs => 'second')"
22 Create and return a new sequence object. The optional "pairs"
23 parameter (a string) controls which of each twin-prime pair of
24 values is returned
25
26 "first" the first of each pair, 3,5,11,17 etc
27 "second" the second of each pair 5,7,13,19 etc
28 "both" both values 3,5,7,11,13,17,19 etc
29 "average" the average of the pair, 4,6,12,8 etc
30
31 "both" is without repetition, so for example 5 belongs to the pair
32 3,5 and 5,7, but is returned in the sequence just once.
33
34 "$bool = $seq->pred($value)"
35 Return true if $value is a twin prime of the given "pairs" type.
36 For example with "second" "pred()" returns true when $value is the
37 second of a pair, ie. "$value-2" is also a prime.
38
39 "$i = $seq->value_to_i_estimate($value)"
40 Return an estimate of the i corresponding to $value. Currently
41 this is the asymptotic by Brun
42
43 value
44 i ~= 2 * C * --------------
45 (log(value))^2
46
47 with Hardy and Littlewood's conjectured twin-prime constant
48 C=0.66016. In practice it's quite close, being too small by a
49 factor between 0.75 and 0.85 in the small to medium size integers
50 this module might calculate.
51
53 Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::SophieGermainPrimes
54
56 <http://user42.tuxfamily.org/math-numseq/index.html>
57
59 Copyright 2010, 2011, 2012, 2013, 2014, 2016, 2019 Kevin Ryde
60
61 Math-NumSeq is free software; you can redistribute it and/or modify it
62 under the terms of the GNU General Public License as published by the
63 Free Software Foundation; either version 3, or (at your option) any
64 later version.
65
66 Math-NumSeq is distributed in the hope that it will be useful, but
67 WITHOUT ANY WARRANTY; without even the implied warranty of
68 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
69 General Public License for more details.
70
71 You should have received a copy of the GNU General Public License along
72 with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.
73
74
75
76perl v5.34.0 2021-07-22 Math::NumSeq::TwinPrimes(3)