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.

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