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

NAME

Math::NumSeq::Padovan -- Padovan sequence

SYNOPSIS

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

DESCRIPTION

In progress ...

This is the Padovan sequence,

    1, 1, 1, 2, 2, 3, 4, 5, 7, 9, 12, 16, 21, 28, 37, 49, 65, ...

which is the recurrence

    P[i] = P[i-2] + P[i-3]

starting from 1,1,1. So for example 28 is 12+16.

    12, 16, 21, 28

     |   |       ^
     |   |       |
     +---+---add-+

The recurrence is the same as the Perrin sequence (Math::NumSeq::Perrin) but with different staring values.

Triangles

There's an attractive geometric interpretation of these numbers.

    +-----------------------------------+
     \                                 / \
      \                               /   \
       \                             /     \
        \                           /       \
         \                         /         \
          \                       /           \
           \         9           /             \
            \                   /       7       \
             \                 /                 \
              \               /                   \
               \             /                     \
                \           /                       \
                 \         /                         \
                  \       +-------+-------------------+
                   \     / \  2  /1\                 /
                    \   / 2 \   +---+               /
                     \ /     \ /1\1/ \             /
                      +-------+---+   \     5     /
                       \         /     \         /
                        \   3   /       \       /
                         \     /    4    \     /
                          \   /           \   /
                           \ /             \ /
                            +---------------+

The pattern starts from an equilateral triangle of side length 1, the lower left one shown above. Then put a new triangle successively to the right, left and lower sides, each time the side length of the triangle is the width of the figure so far.

The effect is to add the immediately preceding triangle side and the side of the 5th previous,

    P[i] = P[i-1] + P[i-5]

This is the same as the i-2,i-3 formula shown above since

    P[i] = P[i-2] + P[i-3]          # formula above
         = P[i-4]+P[i-5] + P[i-3]
         = P[i-3]+P[i-4] + P[i-5]
         = P[i-1] + P[i-5]          # geometric form

FUNCTIONS

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

$seq = Math::NumSeq::Padovan->new ()
$seq = Math::NumSeq::Padovan->new (language => $str)

Create and return a new sequence object.

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

Return the number of letters in $i written out in the selected language.

SEE ALSO

Math::NumSeq, Math::NumSeq::Perrin

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