The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::LemoineCount -- number of representations as P+2*Q for primes P,Q

SYNOPSIS

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

DESCRIPTION

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.

Odd Numbers

Option 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

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

FUNCTIONS

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.

Random Access

$value = $seq->ith($i)

Return the sequence value at $i, being the number of ways $i can be represented as P+2*Q for primes P,Q. or with the on_values=>'odd' option the number of ways for 2*$i+1.

This requires checking all primes up to $i or 2*$i+1 and the current code has a hard limit of 2**24 in the interests of not going into a near-infinite loop.

SEE ALSO

Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::GoldbachCount

HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

LICENSE

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/>.