Documentation

Sequencelib.Recaman

Recamán's sequence #

The Recamán's sequence appears in the logo of the OEIS.

$$ a(n) = \begin{cases} 0, & \text{if } n = 0, \\ a(n-1) - n, & \text{if } a(n-1) - n \ge 0 \text{ and not already in the sequence,} \\ a(n-1) + n, & \text{otherwise.} \end{cases} $$

@[irreducible]
def Recaman :
ℕ → ℕ
Equations
Instances For

    OEIS Identifier

    Equations
    Instances For

      OEIS sequence offset

      Equations
      Instances For
        @[simp]
        theorem Recaman_zero :
        @[simp]
        theorem Recaman_one :
        @[simp]
        theorem Recaman_two :
        @[simp]
        theorem Recaman_three :
        @[simp]
        theorem Recaman_four :
        @[simp]
        theorem Recaman_five :
        @[simp]
        theorem Recaman_six :
        Recaman 6 = 13
        @[simp]
        theorem Recaman_seven :
        Recaman 7 = 20
        theorem Recaman_nonneg (n : ℕ) :
        theorem Recaman_abs (n : ℕ) :
        |↑(Recaman (n + 1)) - ↑(Recaman n)| = ↑n + 1