A363086 a(0)=a(1)=1. For n>1, let c=count of all occurrences of a(n-1) in the list so far. If c < abs(a(n-1)), then a(n)=c-a(n-1). Otherwise, a(n)=c.
1, 1, 2, -1, 1, 3, -2, 3, -1, 2, 2, 3, 3, 4, -3, 4, -2, 2, 4, -1, 3, 5, -4, 5, -3, 5, -2, 3, 6, -5, 6, -4, 6, -3, 3, 7, -6, 7, -5, 7, -4, 7, -3, 4, 4, 5, -1, 4, 6, -2, 4, 7, -2, 5, 5, 6, -1, 5, 7, -1, 6, 6, 7, 7, 8, -7, 8, -6, 8, -5, 8, -4, 4, 8, -3, 5, 8, -2
Offset: 0
Examples
a(0) = 1 a(1) = 1 a(2) = 2. Two 1's in the list so far. 2 > abs(1). c = 2. a(3) = -1. One 2 in the list so far. 1 < abs(2). 1 - 2 = -1. a(4) = 1. One -1 in the list so far. 1 = abs(-1). c = 1.
Links
- Gavin Lupo, Table of n, a(n) for n = 0..50000
- Gavin Lupo, Image of the first 1000000 terms
Crossrefs
Cf. A363083.
Programs
-
Python
from itertools import islice from collections import Counter def agen(): # generator of terms an, c = 1, Counter([1, 1]) yield from [1, 1] while True: an = c[an]-an if c[an] < abs(an) else c[an] c[an] += 1 yield an print(list(islice(agen(), 80))) # Michael S. Branicky, May 19 2023
Comments