Skip to content

PadovanSequence ​

The Padovan sequence 1,0,0,1,0,1,1,1,2,…1, 0, 0, 1, 0, 1, 1, 1, 2, … as a lazy indexed collection.

PadovanSequencean=an−2+an−3a_n = a_{n-2} + a_{n-3}, a0=1a_0 = 1, a1=a2=0a_1 = a_2 = 0, an infinite indexed collection.

Domain: Collections

Details
  • A lazy indexed collection: Count(PadovanSequence)=+∞Count(PadovanSequence) = +\infty, and At(PadovanSequence,1)=a0=1At(PadovanSequence, 1) = a_0 = 1.
  • OEIS A000931, starting exactly at its offset-0 term: 1,0,0,1,0,1,1,1,2,2,3,…1, 0, 0, 1, 0, 1, 1, 1, 2, 2, 3, …. The sequence dips through index 4 before climbing forever from a4=0a_4 = 0 on.
  • Membership goes through Element: Element(9,PadovanSequence)Element(9, PadovanSequence) is true (it's a16a_{16}, following …,7,9,12,……,7,9,12,…), Element(6,PadovanSequence)Element(6, PadovanSequence) is false.

Definition

Epsil, as the implementation runs it.

count()

PositiveInfinity

unrank(_r)

Fold(
      Function([wk_w[2], wk_w[3], wk_w[1] + wk_w[2]], wk_w, wk_n),
      [1, 0, 0],
      Range(0, _r - 1, 1),
    )[1]

rank(_x)

Fold(
      Function(
                wk_w if wk_n >= 4 && wk_w[1] > _x else [
                                                         wk_w[2],
                                                         wk_w[3],
                                                         wk_w[1] + wk_w[2],
                                                         wk_n if wk_w[4] < 0 &&
                                                                 wk_w[1] == _x else wk_w[4],
                                                       ],
                wk_w,
                wk_n,
              ),
      [1, 0, 0, -1],
      Range(
             0,
             3 * (Apply(
                         (fl_r: list<integer>) => fl_r[2],
                         Fold(Function(
                                        [
                                          (fl_s[1] - fl_s[1] % 2 ^ fl_k) / 2 ^
                                                                           fl_k,
                                          fl_s[2] + fl_k,
                                        ] if fl_s[1] >= 2 ^ fl_k else fl_s,
                                        fl_s,
                                        fl_k,
                                      ), [_x + 2, 0], [
                                                       8_192,
                                                       4_096,
                                                       2_048,
                                                       1_024,
                                                       512,
                                                       256,
                                                       128,
                                                       64,
                                                       32,
                                                       16,
                                                       8,
                                                       4,
                                                       2,
                                                       1,
                                                     ]),
                       ) + 1) + 12,
             1,
           ),
    )[4] if _x >= 0 else -1

valid(_x)

Fold(
      Function(
                wk_w if wk_n >= 4 && wk_w[1] > _x else [
                                                         wk_w[2],
                                                         wk_w[3],
                                                         wk_w[1] + wk_w[2],
                                                         wk_n if wk_w[4] < 0 &&
                                                                 wk_w[1] == _x else wk_w[4],
                                                       ],
                wk_w,
                wk_n,
              ),
      [1, 0, 0, -1],
      Range(
             0,
             3 * (Apply(
                         (fl_r: list<integer>) => fl_r[2],
                         Fold(Function(
                                        [
                                          (fl_s[1] - fl_s[1] % 2 ^ fl_k) / 2 ^
                                                                           fl_k,
                                          fl_s[2] + fl_k,
                                        ] if fl_s[1] >= 2 ^ fl_k else fl_s,
                                        fl_s,
                                        fl_k,
                                      ), [_x + 2, 0], [
                                                       8_192,
                                                       4_096,
                                                       2_048,
                                                       1_024,
                                                       512,
                                                       256,
                                                       128,
                                                       64,
                                                       32,
                                                       16,
                                                       8,
                                                       4,
                                                       2,
                                                       1,
                                                     ]),
                       ) + 1) + 12,
             1,
           ),
    )[4] >= 0 if _x >= 0 else False

Enumeration

Examples

1 more kept as data, checked against the oracles
About
Examples1
CrosswalkOEIS

See also: Count, At, Element, PerrinSequence