Math::NumSeq::OEIS -- number sequence by OEIS A-number


 use Math::NumSeq::OEIS;
 my $seq = Math::NumSeq::OEIS->new (anum => 'A000032');
 my ($i, $value) = $seq->next;


This module selects a NumSeq by its Online Encyclopedia of Integer Sequences A-number.

If there's NumSeq code implementing the sequence then that's used, otherwise files if available. See Math::NumSeq::OEIS::Catalogue for querying the available A-numbers.

Files should be in an OEIS directory in the user's home directory. It can be the HTML, "internal" format, B-file, or A-file.


    downloaded from:

The "internal" format is more reliable for parsing than the HTML. The B-file or A-file alone can be used, but in that case there's no $seq->description() and only a few of the $seq->characteristic() attributes.

The a000000.txt or b000000.txt files are generally a long list of values (the a.txt longer than the b.txt, when available). Some sequences don't have them, only 30 or 40 sample values from HTML or internal page. Those few samples might be enough for fast growing sequences.

Sometimes more than one NumSeq module can generate a given OEIS sequence. For example Squares and Polygonal k=4 are both A000290. Math::NumSeq::OEIS tries to give the better or faster one.

Sometimes the OEIS has duplicates, ie. two A-numbers which are the same sequence. The code modules are setup with both A-numbers, where known, but the $seq->oeis_anum() method will generally read back as whichever is the "primary" one.


See "FUNCTIONS" in Math::NumSeq for the behaviour common to all path classes.

$seq = Math::NumSeq::OEIS->new (anum => 'A000000')

Create and return a new sequence object.


There's a hard-coded stop at file values bigger than an IV or an NV mantissa (whichever is larger). The idea is not to lose precision reading into a float. Perhaps reading into Math::BigInt would be better, but perhaps when reading progressively unlike the current code which slurps the file in one go.


Math::NumSeq, Math::NumSeq::OEIS::Catalogue



Copyright 2010, 2011 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 <>.