- SEE ALSO
- HOME PAGE
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 can only be written 2+2*2 so just 1 way. But i=9 is 3+2*3=9 and 5+2*2=9 so 2 ways.
on_values => 'odd' gives the count on just the odd numbers, starting i=0 for number of ways "1" can be expressed (none),
0, 0, 0, 1, 2, 2, 2, 2, 4, 2, 3, 3, 3, 4, 4, 2, 5, 3, 4, ...
Lemoine conjectured circa 1894 that all odd i >= 7 can be represented as P+2*Q, which would be a count here always >=1.
Even numbers i are not particularly interesting. An even number must have P even, ie. P=2, so i=2+2*Q for count
count(even i) = 1 if i/2-1 is prime = 0 if not
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::LemoineCount->new ()
$seq = Math::NumSeq::LemoineCount->new (on_values => 'odd')
Create and return a new sequence object.
$value = $seq->ith($i)
Return the sequence value at
$i, being the number of ways
$ican be represented as P+2*Q for primes P,Q. or with the
on_values=>'odd'option the number of ways for
This requires checking all primes up to
2*$i+1and the current code has a hard limit of 2**24 in the interests of not going into a near-infinite loop.
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/>.