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).

This page as a plain text file.
%I A385938 #57 Aug 13 2025 22:28:47
%S A385938 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,
%T A385938 61,18,19,68,20,21,75,22,23,82,24,25,89,26,27,96,28,29,103,30,31,110,
%U A385938 32,33,117,34,35,124,36,37,131,38,39,138,40,41,145,42,43,152,44,45,159
%N 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).
%C A385938 Ternary modular function with three cases based on residue modulo 3.
%C A385938 The function defines a dynamical system with multiple periodic attractors.
%C A385938 Fixed point at 1: a(1) = 1.
%C A385938 From _Miquel Cerda_, Aug 06 2025: (Start)
%C A385938 Every nonnegative integer k appears at least once as a value in the sequence.
%C A385938 Inverse formulas (for possible preimages):
%C A385938 If k is even: one preimage is n = 3*k/2.
%C A385938 If k is odd: one preimage is n = (3*k - 1)/2.
%C A385938 If k == 5 (mod 7): there is an additional preimage: n = 3*(k - 5)/7 + 2. (End)
%H A385938 <a href="/index/Rec#order_06">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,2,0,0,-1).
%F A385938 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
%e A385938 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.
%t A385938 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}]
%o A385938 (PARI) a(n) = if(n%3==0, 2*n/3, if(n%3==1, (2*n+1)/3, (7*n+1)/3))
%o A385938 (Python)
%o A385938 def A385938(n):
%o A385938     q, r = divmod(n,3)
%o A385938     return (q<<1)+r if r<2 else 7*q+5 # _Chai Wah Wu_, Jul 17 2025
%Y A385938 Cf. A385893 (cycle of length 130 in this dynamical system).
%Y A385938 Cf. A332057 (near definition).
%K A385938 nonn,easy
%O A385938 0,3
%A A385938 _Miquel Cerda_, Jul 13 2025