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.
%I A377030 #37 Jul 23 2025 16:06:10 %S A377030 0,3,6,9,7,4,1,2,5,8,8,5,2,1,4,7,9,6,3,0,3,6,9,7,4,1,2,5,8,8,5,2,1,4, %T A377030 7,9,6,3,0,3,6,9,7,4,1,2,5,8,8,5,2,1,4,7,9,6,3,0,3,6,9,7,4,1,2,5,8,8, %U A377030 5,2,1,4,7,9,6,3,0,3,6,9,7,4,1,2,5,8,8,5,2,1,4,7,9,6,3,0 %N A377030 Period 19: repeat [0, 3, 6, 9, 7, 4, 1, 2, 5, 8, 8, 5, 2, 1, 4, 7, 9, 6, 3]. %C A377030 Difference between the multiples of 3 (A008585) and the closest multiple of 19 (A008601). For any two numbers (in this case p=3 and q=19), a sequence is produced consisting of a palindrome cycle. If p and q are coprime, then the cycle length is equal to max(p,q). The biggest number in the sequence will be at most half of max(p,q). Here is a plot of the first cycle of this sequence: %C A377030 9 X X %C A377030 8 X X %C A377030 7 X X %C A377030 6 X X %C A377030 5 X X %C A377030 4 X X %C A377030 3 X X %C A377030 2 X X %C A377030 1 X X %C A377030 0 X X %H A377030 <a href="/index/Rec#order_19">Index entries for linear recurrences with constant coefficients</a>, signature (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1). %F A377030 a(n) = a(n-19). - _David A. Corneth_, Oct 14 2024 %F A377030 a(n) = min(3*n-19*floor(3*n/19), 19*ceil(3*n/19)-3*n). %t A377030 LinearRecurrence[{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},{0, 3, 6, 9, 7, 4, 1, 2, 5, 8, 8, 5, 2, 1, 4, 7, 9, 6, 3},96] (* _James C. McMahon_, Oct 31 2024 *) %o A377030 (C) %o A377030 int p = 3; %o A377030 int q = 19; %o A377030 for (int t = 0;t <= 99;t++) { %o A377030 int closest = 999; %o A377030 for (int i = 0;i <= 99;i++) { %o A377030 int dist=abs(i * q - t * p); %o A377030 if (dist < closest) { %o A377030 closest = dist; %o A377030 } %o A377030 } %o A377030 printf("%i, ", closest); %o A377030 } %o A377030 (PARI) a(n) = my(n3 = 3*n); min(n3 - 19*floor(n3/19), ceil(19*ceil(n3/19) - n3)) \\ _David A. Corneth_, Oct 14 2024 %o A377030 (Python) %o A377030 def A377030(n): return (0, 3, 6, 9, 7, 4, 1, 2, 5, 8, 8, 5, 2, 1, 4, 7, 9, 6, 3)[n%19] # _Chai Wah Wu_, Oct 31 2024 %Y A377030 Cf. A008585, A008601. %K A377030 nonn,easy %O A377030 0,2 %A A377030 _Neil Vaughan_, Oct 13 2024