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
Moritz Stern's diatomic sequence 0,1,1,2,1,3,2,3,etc. It's constructed by successive levels as D(2*i)=D(i) and D(2*i+1)=D(i+1), so effectively the sequence is extended by interleaving the previous level with sums of adjacent terms,
1, i=0
1,2, i=1,2
1,3,2,3, i=3,4,5,6
The last row is a copy of 1,2 interleaving the sums 1+2 and 2+1. For the latter it's the end 2 at i=2 and then the 1 at the start of the next row i=3.
FUNCTIONS
See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.
$seq = Math::NumSeq::SternDiatomic->new ()
-
Create and return a new sequence object.
$bool = $seq->pred($value)
-
Return true if
$value
occurs in the sequence, which means simply$value
=0>.
SEE ALSO
HOME PAGE
http://user42.tuxfamily.org/math-numseq/index.html
LICENSE
Copyright 2011, 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/>.