A135317 Let h(2*n, 1) = 2*n and h(2*n, m) = h(2*n, m-1) + 2 * d(2*n, m) for m > 1, where d(2*n, m) = (least multiple of m not less than h(2*n, m-1)) - h(2*n, m-1). Then d(2*n, m) is eventually 2-periodic as a function of m, and a(n) is defined as d(2*n, 2*m+1) for large m.
0, 1, 2, 0, 1, 2, 3, 4, 0, 3, 4, 5, 1, 2, 3, 6, 0, 1, 4, 5, 6, 2, 5, 6, 7, 8, 0, 7, 8, 9, 3, 4, 5, 1, 2, 3, 6, 7, 10, 4, 7, 8, 0, 1, 2, 9, 10, 11, 5, 8, 9, 12, 6, 7, 10, 11, 12, 8, 9, 10, 0, 3, 4, 13, 1, 2, 5, 6, 11, 3, 4, 9, 14, 0, 1, 10, 11, 12, 2, 7, 8, 13, 5, 6, 9, 12, 13, 7, 10, 11, 14, 15, 16, 14
Offset: 0
Keywords
Examples
h(18,m) for m>=1 goes 18,18,18,22,28,32,38,42,48...so we can take m(18) = 2, then 2*c(18)=28-22=38-32=48-42=...=6, so a(9) = c(18) = 3 and similarly b(18) = 2.
Links
- Andrey Zabolotskiy, Table of n, a(n) for n = 0..20000
- Jon Maiga, Computer-generated formulas for A135317, Sequence Machine.
- Andrey Zabolotskiy, Abercrombie's sequence, Github (formalized Lean proof that this sequence is well-defined).
Programs
-
Mathematica
a[n_] := Module[{h = 2 n, b, c = 0, m = 1}, While[Ceiling[h/(m+1)] != Floor[h/m], m++; b = Mod[-h, m]; h += 2 b; m++; c = Mod[-h, m]; h += 2 c]; c]; Table[a[n], {n, 0, 93}] (* Andrey Zabolotskiy, Apr 29 2023, Dec 25 2024 *)
-
Python
def a(n): h, m, c = 2*n, 1, 0 while (h+m)//(m+1) != h//m: m += 1; b = (-h) % m; h += 2*b m += 1; c = (-h) % m; h += 2*c return c print([a(n) for n in range(30)]) # Andrey Zabolotskiy, Dec 25 2024
Formula
Extensions
Edited by Andrey Zabolotskiy, Apr 29 2023
Comments