|
|
A347325
|
|
Solution to the spectator-first Tantalizer problem.
|
|
1
|
|
|
1, 2, 2, 2, 2, 4, 4, 6, 6, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 6, 6, 8, 8, 14, 14, 16, 16, 14, 14, 16, 16, 22, 22, 24, 24, 22, 22, 24, 24, 30, 30, 32, 32, 30, 30, 32, 32, 22, 22, 24, 24, 22, 22, 24, 24, 30, 30, 32, 32, 30, 30, 32, 32, 22, 22, 24, 24, 22, 22, 24, 24
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
FORMULA
|
a(n) = 2 * (floor(n/2) + 1 - a(floor(n/2))) for n > 1. See Zhang's solution. - Zirui Wang, Jan 02 2022
|
|
PROG
|
(Python)
a = [i for i in range(1, n+1)]
while len(a) != 1:
del a[:len(a)+1:2]
a.reverse()
(Python)
def a(n):
return 1 if n <= 1 else 2 * (n // 2 + 1 - a(n // 2))
(Python)
from math import log, log2
return (-2) ** int(log2(n)) // 3 + 1 + (n & int('a' * int(log(n, 16) + 1), 16))
(PARI) a(n)={my(s=1, v=0); while(n>1, n=n\2; s=-2*s; v-=s*(1+n)); v+s} \\ Andrew Howroyd, Jan 02 2022
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|