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.

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.

Original entry on oeis.org

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

Views

Author

Sameer Khan, May 10 2024

Keywords

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.

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.
		

Programs

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