A377030 Period 19: repeat [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, 3, 6, 9, 7, 4, 1, 2, 5, 8, 8, 5, 2, 1, 4, 7, 9, 6, 3, 0
Offset: 0
Links
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1).
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).
Comments