Math::NumSeq::LemoineCount -- number of representations as P+2*Q for primes P,Q
use Math::NumSeq::LemoineCount; my $seq = Math::NumSeq::LemoineCount->new; my ($i, $value) = $seq->next;
This is a count of how many ways i can be represented as P+2*Q for primes P,Q, starting from i=1.
0, 0, 0, 0, 0, 1, 1, 1, 2, 0, 2, 1, 2, 0, 2, 1, 4, 0, ...
For example i=6 is 2+2*2, just 1 way. Or i=9 is 3+2*3=9 and 5+2*2=9 so 2 ways.
Lemoine conjectured circa 1894 that all odd i >= 7 can be represented as P+2*Q, ie. a count >=1.
An even i must have P even, ie. P=2 as i=2+2*Q. So for even i the count is is 1 if i/2-1 is a prime or 0 if not.
$seq = Math::NumSeq::LemoineCount->new ()
Create and return a new sequence object.
$value = $seq->ith($i)
Return the number of ways $i can be represented as P+2*Q for primes P,Q.
$i
This requires checking all primes up to $i and the current code has a hard limit of 2**24 in the interests of not going into a near-infinite loop.
$bool = $seq->pred($value)
Return true if $value occurs as a count. All counts 0 up occur so this is simply integer $value >= 0.
$value
$value >= 0
Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::GoldbachCount
http://user42.tuxfamily.org/math-numseq/index.html
Copyright 2012 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/>.
To install Math::NumSeq, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Math::NumSeq
CPAN shell
perl -MCPAN -e shell install Math::NumSeq
For more information on module installation, please visit the detailed CPAN module installation guide.