cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A212306 Starting with the positive numbers, each element subtracts its value, a(n), from the next a(n) elements.

Original entry on oeis.org

1, 1, 2, 2, 1, 3, 4, 1, 1, 5, 2, 5, 1, 3, 2, 6, 1, 11, 2, 1, 1, 4, 8, 1, 1, 2, 6, 1, 3, 13, 1, 9, 5, 7, 1, 1, 2, 2, 6, 3, 3, 17, 1, 17, 5, 7, 1, 1, 2, 2, 6, 3, 3, 8, 1, 4, 5, 7, 1, 18, 6, 18, 14, 1, 1, 9, 2, 7, 1, 3, 2, 1, 1, 7, 2, 17, 1, 17, 20, 1, 19, 9, 1, 1
Offset: 1

Views

Author

Gabriel Stauth, Oct 26 2013

Keywords

Comments

When calculating this sequence, each element affects a different number of subsequent terms, so there is no known direct formula for the n-th term.
a(A258353(n)) = 1; a(A258354(n)) = n and a(m) != n for m < A258354(n). - Reinhard Zumkeller, May 27 2015

Examples

			Starting with A000027, the first term is 1 so we subtract 1 from the next 1 terms so the second term becomes 1. Now again we subtract 1 from the next 1 terms and the third term becomes 2. Subtract 2 from the next two terms of A000027 (4 and 5) to get 2 and 3. Subtract 2 from the next 2 terms (the 3 from 5 and 6) to get 1 and 4. The next term is 4 - 1 = 3. To carry on subtract 3 from the next 3 terms.
		

Crossrefs

Generated from A000027.

Programs

  • Haskell
    a212306 n = a212306_list !! (n-1)
    a212306_list = f [1..] where
       f (x:xs) = x : f ((map (subtract x) us) ++ vs)
                  where (us, vs) = splitAt x xs
    -- Reinhard Zumkeller, Dec 16 2013
  • Maple
    b:= proc(n) option remember; local l, t;
          if n=1 then [1$2] else l:= b(n-1); t:= n-l[2];
          zip((x, y)->x+y, [t$t+1], subsop(1=NULL, 2=0, l), 0) fi
        end:
    a:= n-> b(n)[1]:
    seq(a(n), n=1..100);  # Alois P. Heinz, Nov 12 2013
  • Mathematica
    b[n_] := b[n] = Module[{l, t, x, y, m}, If[n == 1, {1, 1}, l = b[n-1]; t = n-l[[2]]; x = Array[t&, t+1]; y = ReplacePart[l, {1 -> Sequence[], 2 -> 0}]; m = Max[Length[x], Length[y]]; Thread[PadRight[x, m] + PadRight[y, m]]]]; a[n_] := b[n] // First; Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Jan 27 2014, after Alois P. Heinz *)
  • PARI
    {a(n)=local(A=vector(n+1,j,j)); for(k=1,n+1, A = Vec(Ser(A) - x^k*A[k]*(1-x^A[k])/(1-x) +x*O(x^n)));A[n]} \\ Paul D. Hanna, Nov 12 2013
    for(n=1,100,print1(a(n),", "))
    
  • PARI
    /* Vector returns 1000 terms: */
    {A=vector(1000,j,j);for(k=1,#A, A = Vec(Ser(A) - x^k*A[k]*(1-x^A[k])/(1-x) +x*O(x^#A)));A} \\ Paul D. Hanna, Nov 12 2013
    

Formula

a(n) is n - the sum of the terms such that a(i) + i >= n.
Each term a(n) is 1 plus the sum of the terms such that a(i) + i + 1 = n.