NAME
Math::NumSeq::GoldbachCount  number of representations as sum of primes P+Q
SYNOPSIS
use Math::NumSeq::GoldbachCount;
my $seq = Math::NumSeq::GoldbachCount>new;
my ($i, $value) = $seq>next;
DESCRIPTION
The number of ways each i can be represented as a sum of two primes P+Q, starting from i=1,
# starting i=1
0, 0, 0, 1, 1, 1, 1, 1, 1, 2, 0, 1, 1, 2, 1, 2, 0, ...
For example i=4 can be represented only as 2+2 so just 1 way. Or i=10 is 3+7 and 5+5 so 2 ways.
Even Numbers
Option on_values => 'even'
gives the count on just the even numbers, starting i=1 for number of ways "2" can be expressed (none),
# starting i=1
0, 1, 1, 1, 2, 1, 2, 2, 2, 2, 3, 3, 3, 2, 3, 2, 4, 4, ...
Goldbach's famous conjecture is that for an even i >= 4 there's always at least one P+Q=i, which would be a count here always >= 1.
Odd Numbers
Odd numbers i are not particularly interesting. An odd number can only be i=2+Prime, so the count is simply
count(odd i) = 1 if i2 prime
0 if not
FUNCTIONS
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::GoldbachCount>new ()
$seq = Math::NumSeq::GoldbachCount>new (on_values => 'even')

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 a sum of primes P+Q, or with theon_values=>'even'
option the number of ways for2*$i
.This requires checking all primes up to
$i
(or2*$i
) and the current code has a hard limit of 2**24 in the interests of not going into a nearinfinite loop. $bool = $seq>pred($value)

Return true if
$value
occurs as a count. All counts 0 upwards occur so this is simply integer$value >= 0
.
SEE ALSO
Math::NumSeq, Math::NumSeq::Primes, Math::NumSeq::LemoineCount, Math::NumSeq::PrimeFactorCount
HOME PAGE
http://user42.tuxfamily.org/mathnumseq/index.html
LICENSE
Copyright 2012, 2013 Kevin Ryde
MathNumSeq 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.
MathNumSeq 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 MathNumSeq. If not, see <http://www.gnu.org/licenses/>.