A372696 For n>1, if n mod a(n-1) = 0 or a(n-1) mod n = 0, set a(n) = n + a(n-1); otherwise a(n) = abs(n - a(n-1)). Start with a(1)=1.
1, 3, 6, 2, 3, 9, 2, 10, 1, 11, 22, 10, 3, 11, 4, 20, 3, 21, 2, 22, 1, 23, 46, 22, 3, 23, 4, 32, 3, 33, 2, 34, 1, 35, 70, 34, 3, 35, 4, 44, 3, 45, 2, 46, 1, 47, 94, 46, 3, 47, 4, 56, 3, 57, 2, 58, 1, 59, 118, 58, 3, 59, 4, 68, 3, 69, 2, 70, 1, 71, 142, 70, 3
Offset: 1
Examples
For a(2), as a(1) = 1 and n = 2 and 2 mod 1 = 0, use 2+1 = 3. For a(3), as a(2) = 3 and n = 3 and 3 mod 3 = 0, use 3+3 = 6. For a(4), as a(3) = 6 and n = 4 and 6 mod 4 != 0 and 4 mod 6 != 0, use abs(4-6) = 2.
Links
- Paolo Xausa, Table of n, a(n) for n = 1..10000
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,-1).
Programs
-
Mathematica
Block[{n = 1}, NestList[If[Divisible[++n, #] || Divisible[#, n], n + #, Abs[n - #]] &, 1, 100]] (* Paolo Xausa, May 20 2024 *)
Comments