OFFSET
0,2
COMMENTS
This sequence exhibits large runs of consecutive equal values.
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..10000
Rémy Sigrist, PARI program
FORMULA
a(A091945(n)) = n (this is the first occurrence of n in the sequence).
a(2*n) = a(2*n-1) for any n > 0.
EXAMPLE
Sequence begins:
n a(n) A002487(n)
-- ---- ----------
0 1 0
1 2 1
2 2 1
3 3 2
4 3 1
5 4 3
6 4 2
7 4 3
8 4 1
9 5 4
10 5 3
11 6 5
12 6 2
13 6 5
14 6 3
15 6 4
16 6 1
17 6 5
18 6 4
19 7 7
PROG
(PARI) \\ See Links section.
(Python)
def A385991(n):
if n==0: return 1
a, b, s, c = 0, 1, {0, 1}, 2
for i in range(n-1):
a, b = b, ((a//b<<1)+1)*b-a
if b not in s:
c += 1
s.add(b)
return c # Chai Wah Wu, Jul 17 2025
CROSSREFS
KEYWORD
nonn
AUTHOR
Rémy Sigrist, Jul 14 2025
STATUS
approved
