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-3 of 3 results.

A332056 a(1) = 1, then a(n+1) = a(n) - (-1)^a(n) Sum_{k=1..n} a(k): if a(n) is odd, add the partial sum, else subtract.

Original entry on oeis.org

1, 2, -1, 1, 4, -3, 1, 6, -5, 1, 8, -7, 1, 10, -9, 1, 12, -11, 1, 14, -13, 1, 16, -15, 1, 18, -17, 1, 20, -19, 1, 22, -21, 1, 24, -23, 1, 26, -25, 1, 28, -27, 1, 30, -29, 1, 32, -31, 1, 34, -33, 1, 36, -35, 1, 38, -37, 1, 40, -39
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Feb 24 2020

Keywords

Comments

The terms display a 3-quasiperiodic pattern (1, 2m, 1-2m), m = 1, 2, 3, ...
Conjecture from Barker confirmed by recurrence formula. - Ray Chandler, Jul 31 2025

Examples

			a(1) = 1 is odd, so we add the partial sum (so far equal to a(1)) to get the next term, a(2) = 2.
Now a(2) = 2 is even, so we subtract the partial sum 1 + 2 = 3 to get a(3) = -1.
And so on.
		

Crossrefs

See A332057 for the partial sums.

Programs

  • PARI
    s=-a=1; vector(100,n, a-=(-1)^a*s+=a)
    
  • PARI
    apply( {A332056(n)=[1-n\3*2,1,n\/3*2][n%3+1]}, [1..99])

Formula

a(3k-2) = 1, a(3k-1) = 2k, a(3k) = 1 - 2k, for all k >= 1.
From Colin Barker, Feb 25 2020: (Start)
G.f.: x*(1 + x)*(1 + 2*x + x^3) / ((1 - x)*(1 + x + x^2)^2).
a(n) = -a(n-1) - a(n-2) + a(n-3) + a(n-4) + a(n-5) for n>5.
(End)

A385938 a(n) = 2*n/3 if n == 0 (mod 3), (2*n+1)/3 if n == 1 (mod 3), (7*n+1)/3 if n == 2 (mod 3).

Original entry on oeis.org

0, 1, 5, 2, 3, 12, 4, 5, 19, 6, 7, 26, 8, 9, 33, 10, 11, 40, 12, 13, 47, 14, 15, 54, 16, 17, 61, 18, 19, 68, 20, 21, 75, 22, 23, 82, 24, 25, 89, 26, 27, 96, 28, 29, 103, 30, 31, 110, 32, 33, 117, 34, 35, 124, 36, 37, 131, 38, 39, 138, 40, 41, 145, 42, 43, 152, 44, 45, 159
Offset: 0

Views

Author

Miquel Cerda, Jul 13 2025

Keywords

Comments

Ternary modular function with three cases based on residue modulo 3.
The function defines a dynamical system with multiple periodic attractors.
Fixed point at 1: a(1) = 1.
From Miquel Cerda, Aug 06 2025: (Start)
Every nonnegative integer k appears at least once as a value in the sequence.
Inverse formulas (for possible preimages):
If k is even: one preimage is n = 3*k/2.
If k is odd: one preimage is n = (3*k - 1)/2.
If k == 5 (mod 7): there is an additional preimage: n = 3*(k - 5)/7 + 2. (End)

Examples

			a(0) = 2*0/3 = 0. a(1) = (2*1+1)/3 = 1. a(2) = (7*2+1)/3 = 5. a(3) = 2*3/3 = 2.
		

Crossrefs

Cf. A385893 (cycle of length 130 in this dynamical system).
Cf. A332057 (near definition).

Programs

  • Mathematica
    a[x_] := Which[Mod[x, 3] == 0, 2*x/3, Mod[x, 3] == 1, (2*x + 1)/3, Mod[x, 3] == 2, (7*x + 1)/3]; Table[a[n], {n, 0, 50}]
  • PARI
    a(n) = if(n%3==0, 2*n/3, if(n%3==1, (2*n+1)/3, (7*n+1)/3))
    
  • Python
    def A385938(n):
        q, r = divmod(n,3)
        return (q<<1)+r if r<2 else 7*q+5 # Chai Wah Wu, Jul 17 2025

Formula

G.f.: x*(1+5*x+2*x^2+x^3+2*x^4) / ( (x-1)^2*(1+x+x^2)^2 ). - R. J. Mathar, Jul 30 2025

A332059 Absolute value of first differences, or sum of digits of the first n terms of A332058.

Original entry on oeis.org

1, 3, 4, 7, 8, 10, 18, 26, 33, 46, 58, 68, 83, 91, 107, 122, 132, 146, 153, 169, 187, 203, 214, 232, 248, 269, 280, 299, 316, 334, 344, 356, 373, 394, 417, 437, 453, 466, 486, 497, 510, 517, 538, 548, 566, 583, 598, 609, 623
Offset: 1

Views

Author

Eric Angelini and M. F. Hasler, Feb 25 2020

Keywords

Crossrefs

See A332057 for the variant corresponding to A332056 instead of A332058.

Programs

Showing 1-3 of 3 results.