A383730 a(0) = 0, a(n) = a(n-1) + A002260(n) * (-1)^(n-1) if not already in the sequence, otherwise a(n) = a(n-1) - A002260(n) * (-1)^(n-1).
0, 1, 2, 4, 3, 5, 8, 9, 7, 10, 6, 5, 7, 4, 8, 13, 12, 14, 11, 15, 20, 26, 25, 27, 24, 28, 23, 29, 22, 21, 19, 16, 20, 15, 21, 14, 22, 21, 23, 20, 24, 19, 25, 32, 40, 49, 48, 50, 47, 51, 46, 52, 45, 53, 44, 54, 55, 57, 60, 64, 59, 65, 58, 66, 75, 85, 74, 73, 71
Offset: 0
Examples
a(1) = 0 + 1. a(2) = 0 + 1 + 1 = 2, since 0 + 1 - 1 = 0 already appears in the sequence, as a(0) = 0. a(6) = 0 + 1 + 1 + 2 - 1 + 2 + 3 = 8.
Links
- Markel Zubia, Table of n, a(n) for n = 0..9999
- Markel Zubia, Plot of the first 100k terms
- Markel Zubia, Close-up of the fractal-like pattern
- Markel Zubia, Plot of the first 10M terms
- Markel Zubia, Plot of the first 1B terms
Crossrefs
Programs
-
Python
def a(n): t, k, curr = 1, 1, 0 seen = set() for i in range(n): seen.add(curr) step = (-1)**i * t if curr + step not in seen: curr = curr + step else: curr = curr - step t += 1 if t > k: t, k = 1, k + 1 return curr
Comments