NAME
Math::NumSeq::SternDiatomic  Stern's diatomic sequence
SYNOPSIS
use Math::NumSeq::SternDiatomic;
my $seq = Math::NumSeq::SternDiatomic>new;
my ($i, $value) = $seq>next;
DESCRIPTION
This is Moritz Stern's diatomic sequence
0, 1, 1, 2, 1, 3, 2, 3, ...
It's constructed by successive levels as D(2*i)=D(i) and D(2*i+1)=D(i)+D(i+1), so effectively the sequence is extended by interleaving the previous level with sums of adjacent terms,
0, i=0
1, i=1
1, 2, i=2,3
1, 3, 2, 3, i=4,5,6,7
1,4,3,5,2,5,3,4, i=8,9,...,15
For example the i=4 row is a copy of the preceding 1,2 with sums 1+2 and 2+1 interleaved. The new entry at the end of each row is the sum of the last of the previous row and the first of the current row (which is always 1).
FUNCTIONS
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
Random Access
$value = $seq>ith($i)

Return the
$i
'th value of the sequence. $bool = $seq>pred($value)

Return true if
$value
occurs in the sequence, which means simply integer$value>=0
.
SEE ALSO
HOME PAGE
http://user42.tuxfamily.org/mathnumseq/index.html
LICENSE
Copyright 2011, 2012 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/>.