OFFSET

1,2

COMMENTS

Starting at n=5, the sequence follows a set pattern every 12 terms: a(n) = n-2, 3, n-3, 4, n+4, 3, n+3, 2, n+2, 1, n+1, 2n according as n == 0 to 11 (mod 12), respectively.

This means a new peak is reached every 12th term, starting from n = 11.

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).

EXAMPLE

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.

MATHEMATICA

Block[{n = 1}, NestList[If[Divisible[++n, #] || Divisible[#, n], n + #, Abs[n - #]] &, 1, 100]] (* Paolo Xausa, May 20 2024 *)

CROSSREFS

KEYWORD

nonn,easy

AUTHOR

Sameer Khan, May 10 2024

STATUS

approved