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.

A377030 Period 19: repeat [0, 3, 6, 9, 7, 4, 1, 2, 5, 8, 8, 5, 2, 1, 4, 7, 9, 6, 3].

Original entry on oeis.org

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, 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, 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
Offset: 0

Views

Author

Neil Vaughan, Oct 13 2024

Keywords

Comments

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:
9 X X
8 X X
7 X X
6 X X
5 X X
4 X X
3 X X
2 X X
1 X X
0 X X

Crossrefs

Programs

  • C
    int p = 3;
    int q = 19;
    for (int t = 0;t <= 99;t++) {
    	int closest = 999;
    	for (int i = 0;i <= 99;i++) {
    		int dist=abs(i * q - t * p);
    		if (dist < closest) {
    			closest = dist;
    		}
    	}
    	printf("%i, ", closest);
    }
    
  • Mathematica
    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 *)
  • 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
    
  • Python
    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

Formula

a(n) = a(n-19). - David A. Corneth, Oct 14 2024
a(n) = min(3*n-19*floor(3*n/19), 19*ceil(3*n/19)-3*n).