OFFSET
0,2
FORMULA
MAPLE
a := n -> modp(igcd(2*n, 4^n)^(2*n + 1), (2^(2*n + 1) - 1)^2):
seq(a(n), n = 0..19);
PROG
(SageMath)
def v2(n): return valuation(2*n, 2)
def a(n):
if n == 0: return 0
return 4^n*(v2(n) + 1) if n % 2 else 2*4^n*v2(n) - v2(n//2)
print([a(n) for n in range(0, 25)])
(PARI) a(n) = lift(Mod(gcd(2*n, 4^n), (2^(2*n + 1) - 1)^2)^(2*n + 1)); \\ Michel Marcus, Mar 27 2024
(Python)
def A371402(n): return ((~n & n-1).bit_length()+2<<(n<<1) if n&1 else ((m:=(~n & n-1).bit_length())+1<<(n<<1)+1)-m) if n else 0 # Chai Wah Wu, Mar 27 2024
CROSSREFS
KEYWORD
nonn
AUTHOR
Peter Luschny, Mar 26 2024
STATUS
approved