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.

Showing 1-4 of 4 results.

A008344 a(1)=0; thereafter a(n+1) = a(n) - n if a(n) >= n otherwise a(n+1) = a(n) + n.

Original entry on oeis.org

0, 1, 3, 0, 4, 9, 3, 10, 2, 11, 1, 12, 0, 13, 27, 12, 28, 11, 29, 10, 30, 9, 31, 8, 32, 7, 33, 6, 34, 5, 35, 4, 36, 3, 37, 2, 38, 1, 39, 0, 40, 81, 39, 82, 38, 83, 37, 84, 36, 85, 35, 86, 34, 87, 33, 88, 32, 89, 31, 90, 30, 91, 29, 92, 28, 93, 27, 94, 26, 95, 25, 96, 24, 97, 23, 98
Offset: 1

Views

Author

Keywords

Comments

p^a(n) = A084110(p^(n-1)) for n>1 and p prime. - Reinhard Zumkeller, May 12 2003
For n > 1: a(A029858(n)) = A029858(n) and a(A003462(n)) = 0. - Reinhard Zumkeller, May 09 2012
Absolute first differences of A085059; abs(a(n+1)-a(n)) = n, see also A086283. - Reinhard Zumkeller, Oct 17 2014
For n>3, when a(n) = 3, a(n+1) is in A116970. - Bill McEachen, Oct 03 2023

Crossrefs

Equals A085059(n)-1.
Cf. A076042 (based on squares).

Programs

  • Haskell
    a008344 n = a008344_list !! (n-1)
    a008344_list = 0 : f 0 [1..] where
       f x (z:zs) = y : f y zs where y = if x < z then x + z else x - z
    -- Reinhard Zumkeller, Oct 17 2014, May 08 2012
    
  • Maple
    A008344 := proc(n) option remember; if n = 0 then 0 elif A008344(n-1) >= (n-1) then A008344(n-1)-(n-1) else A008344(n-1)+(n-1); fi; end;
  • Mathematica
    a[1]=0; a[n_] := a[n]=If[a[n-1]>=n-1, a[n-1]-n+1, a[n-1]+n-1]
    Transpose[ NestList[ If[First[#]>=Last[#],{First[#]-Last[#],Last[#]+1}, {First[#]+Last[#],Last[#]+1}]&,{0,1},80]][[1]] (* Harvey P. Dale, Jun 20 2011 *)
    s = 0; Table[If[s < n, s = s + n, s = s - n], {n, 0, 80}] (* Horst H. Manninger, Dec 03 2018 *)
  • PARI
    a(n) = my(expo = logint(2*n+1, 3), res = n - (3^expo-1)/2); if(res==0, 0, if(res%2, (3^expo-res)/2, 3^expo-1+res/2)) \\ Jianing Song, May 25 2021

Formula

This is a concatenation S_0, S_1, S_2, ... where S_i = [b_0, b_1, ..., b_{3^(i+1)-1}] with b_0 = 0, b_{2j-1} = k+1-j, b_{2j} = 2k+j (j=1..k), k=(3^(i+1)-1)/2. E.g. S_0 = [0, 1, 3], S_1 = [0, 4, 9, 3, 10, 2, 11, 1, 12].
a((3^n-1)/2) = 0; a((3^n-1)/2 + 2k-1) = (3^n+1)/2 - k for 1 <= k <= (3^n-1)/2; a((3^n-1)/2 + 2k) = 3^n - 1 + k for 1 <= k < (3^n-1)/2. - Benoit Cloitre, Jan 09 2003 [Corrected by Jianing Song, May 25 2021]
a(n) = (n-1+a(n-1)) mod (2*(n-1)). - Jon Maiga, Jul 09 2021

Extensions

Name edited by Dmitry Kamenetsky, Feb 14 2017

A060816 a(0) = 1; a(n) = (5*3^(n-1) - 1)/2 for n > 0.

Original entry on oeis.org

1, 2, 7, 22, 67, 202, 607, 1822, 5467, 16402, 49207, 147622, 442867, 1328602, 3985807, 11957422, 35872267, 107616802, 322850407, 968551222, 2905653667, 8716961002, 26150883007, 78452649022, 235357947067, 706073841202
Offset: 0

Views

Author

Jason Earls, Apr 29 2001

Keywords

Comments

From Erich Friedman's math magic page 2nd paragraph under "Answers" section.
Let A be the Hessenberg matrix of order n, defined by: A[1,j] = 1, A[i,i] = 2,(i>1), A[i,i-1] = -1, and A[i,j] = 0 otherwise. Then, for n >= 1, a(n) = (-1)^n*charpoly(A,-1). - Milan Janjic, Jan 26 2010
If n > 0 and H = hex number (A003215), then 9*H(a(n)) - 2 = H(a(n+1)), for example 9*H(2) - 2 = 9*19 - 2 = 169 = H(7). For n > 2, this is a subsequence of A017209, see formula. - Klaus Purath, Mar 31 2021
Consider the Tower of Hanoi puzzle of order n (i.e., with n rings to be moved). Label each ring with a distinct symbol from an alphabet of size n. Construct words by performing moves according to the standard rules of the puzzle, recording the corresponding symbol each time a ring is moved. To ensure finiteness, we forbid returning to any previously encountered state. Additionally, we impose the constraint that the same ring cannot be moved twice in succession. Then, a(n) is the number of distinct words that can be formed under these rules. - Thomas Baruchel, Jul 22 2025

Crossrefs

Cf. A005030 (first differences), A244762 (partial sums).

Programs

Formula

The following is a summary of formulas added over the past 18 years.
a(n) = A057198(n) - 1.
a(n) = 3*a(n-1) + 1; with a(0)=1, a(1)=2. - Jason Earls, Apr 29 2001
From Henry Bottomley, May 01 2001: (Start)
For n>0, a(n) = a(n-1)+5*3^(n-2) = a(n-1)+A005030(n-2).
For n>0, a(n) = (5*A003462(n)+1)/3. (End)
From Colin Barker, Apr 24 2012: (Start)
a(n) = 4*a(n-1) - 3*a(n-2) for n > 2.
G.f.: (1-2*x+2*x^2)/((1-x)*(1-3*x)). (End)
a(n+1) = A134931(n) + 1. - Philippe Deléham, Apr 14 2013
For n > 0, A008343(a(n)) = 0. - Dmitry Kamenetsky, Feb 14 2017
For n > 0, a(n) = floor(3^n*5/6). - M. F. Hasler, Apr 06 2019
From Klaus Purath, Mar 31 2021: (Start)
a(n) = A017209(a(n-2)), n > 2.
a(n) = 2 + Sum_{i = 0..n-2} A005030(i).
a(n+1)*a(n+2) = a(n)*a(n+3) + 20*3^n, n > 1.
a(n) = 3^n - A007051(n-1). (End)
E.g.f.: (5*exp(3*x) - 3*exp(x) + 4)/6. - Stefano Spezia, Aug 28 2023

Extensions

Edited by M. F. Hasler, Apr 06 2019 and by N. J. A. Sloane, Apr 09 2019

A046901 a(n) = a(n-1) - n if a(n-1) > n, else a(n) = a(n-1) + n.

Original entry on oeis.org

1, 3, 6, 2, 7, 1, 8, 16, 7, 17, 6, 18, 5, 19, 4, 20, 3, 21, 2, 22, 1, 23, 46, 22, 47, 21, 48, 20, 49, 19, 50, 18, 51, 17, 52, 16, 53, 15, 54, 14, 55, 13, 56, 12, 57, 11, 58, 10, 59, 9, 60, 8, 61, 7, 62, 6, 63, 5, 64, 4, 65, 3, 66, 2, 67, 1, 68, 136, 67, 137
Offset: 1

Views

Author

Keywords

Comments

Variation (1) on Recamán's sequence A005132.
a(A134931(n-1)) = 1. - Reinhard Zumkeller, Jan 31 2013

Crossrefs

Programs

  • Haskell
    a046901 n = a046901_list !! (n-1)
    a046901_list = scanl1 (\u v -> if u > v then u - v else u + v) [1..]
    -- Reinhard Zumkeller, Dec 07 2015, Jan 31 2013
  • Maple
    A046901 := proc(n) option remember; if n = 1 then 1 else if A046901(n-1)>n then A046901(n-1)-n else A046901(n-1)+n; fi; fi; end;
  • Mathematica
    a[1]=1;a[n_]:=a[n]=If[a[n-1]>n,a[n-1]-n,a[n-1]+n]; Table[a[i],{i,70}]  (* Harvey P. Dale, Apr 01 2011 *)
    nxt[{n_,a_}]:={n+1,If[a>n+1,a-n-1,a+n+1]}; NestList[nxt,{1,1},70][[All,2]] (* Harvey P. Dale, Jun 01 2019 *)
  • PARI
    a(n)=if(n<2,1,a(n-1)-if(sign(n-a(n-1))+1,-1,1)*n);
    

Formula

This is a concatenation S_0, S_1, S_2, ... where S_i = [b_0, b_1, ..., b_{k-1}], k=5*3^i, with b_0 = 1, b_{2j} = k+j, b_{2j+1} = (k+1)/2-j. E.g., S_0 = [1, 3, 6, 2, 7].
For any m>=1, for k such that 5*3^k+3>12m, a((5*3^k+3-12*m)/6)= m. For example, for k>=1, a((5*3^k-9)/6) = 1. - Benoit Cloitre, Oct 31 2002
a(n) = A008343(n+1) + 1. - Jon Maiga, Jul 09 2021

A363653 a(1) = 1; for n > 1, a(n) = a(n-1) - A000005(n) if a(n) strictly positive, else a(n) = a(n-1) + A000005(n).

Original entry on oeis.org

1, 3, 1, 4, 2, 6, 4, 8, 5, 1, 3, 9, 7, 3, 7, 2, 4, 10, 8, 2, 6, 2, 4, 12, 9, 5, 1, 7, 5, 13, 11, 5, 1, 5, 1, 10, 8, 4, 8, 16, 14, 6, 4, 10, 4, 8, 6, 16, 13, 7, 3, 9, 7, 15, 11, 3, 7, 3, 1, 13, 11, 7, 1, 8, 4, 12, 10, 4, 8, 16, 14, 2, 4, 8, 2, 8, 4, 12, 10, 20, 15, 11, 9, 21
Offset: 1

Views

Author

Ctibor O. Zizka, Jun 13 2023

Keywords

Comments

Variation on Recamán's sequence A005132.

Examples

			a(1) = 1
a(2) = 1 + A000005(2) = 3
		

Crossrefs

Programs

  • Mathematica
    a[1] = 1; a[n_] := a[n] = Module[{d = DivisorSigma[0, n]}, If[a[n - 1] > d, a[n - 1] - d, a[n - 1] + d]]; Array[a, 100] (* Amiram Eldar, Jun 13 2023 *)
Showing 1-4 of 4 results.