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.

A122797 A P_3-stuttered arithmetic progression with a(n+1) = a(n) if n is a triangular number, a(n+1) = a(n) + 1 otherwise.

Original entry on oeis.org

1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 16, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 79, 80, 81, 82, 83, 84, 85, 86, 87
Offset: 1

Views

Author

Grady Bullington (bullingt(AT)uwosh.edu), Sep 14 2006

Keywords

Comments

P_3(i) = the i-th triangular number.
As a triangle [1; 1,2; 2,3,4; ...], row sums = A064808: (1, 3, 9, 22, 45, 81, ...). - Gary W. Adamson, Aug 10 2007
a(n) = n - A003056(n-1). - Reinhard Zumkeller, Feb 12 2012

Crossrefs

Programs

  • Haskell
    a122797 n = a122797_list !! (n-1)
    a122797_list  = 1 : zipWith (+) a122797_list (map ((1 -) . a010054) [1..])
    -- Reinhard Zumkeller, Feb 12 2012
    
  • Mathematica
    nxt[{n_,a_}]:={n+1,If[OddQ[Sqrt[8n+1]],a,a+1]}; NestList[nxt,{1,1},100][[All,2]] (* Harvey P. Dale, Oct 10 2018 *)
  • PARI
    isTriang(n) = {if (! issquare(8*n+1), return (0)); return (1);}
    lista(m) = {aa = 1; for (i=1, m, print1(aa, ", "); if (! isTriang(i), aa = aa + 1););} \\ Michel Marcus, Apr 01 2013
    
  • Python
    from math import isqrt
    def A122797(n): return n+1-(k:=isqrt(m:=n<<1))-int((m<<2)>(k<<2)*(k+1)+1) # Chai Wah Wu, Jul 26 2022

Formula

a(n) = A001614(n) - n + 1.

Extensions

Definition corrected by Michel Marcus, Apr 01 2013