OFFSET
0,2
COMMENTS
LINKS
Tilman Piesk, Table of n, a(n) for n = 0..4095
Tilman Piesk, Boolean Walsh functions and corresponding balloons
Tilman Piesk, First 32 entries in little-endian binary
FORMULA
EXAMPLE
Let n = 25 = 1 + 8 + 16 = 2^0 + 2^3 + 2^4.
Then a(n) = 65794 = 2 + 256 + 65536 = 2^(2^0) + 2^(2^3) + 2^(2^4).
The binary indices of n are {0, 3, 4}. Those of a(n) are {1, 8, 16}.
MAPLE
a := proc(n) select(d -> d[2] <> 0, ListTools:-Enumerate(convert(n, base, 2))):
add(2^(2^(%[j][1] - 1)), j = 1..nops(%)) end: seq(a(n), n = 0..34); # Peter Luschny, Oct 31 2022
MATHEMATICA
a[n_] := Total[2^(2^Range[If[n == 0, 1, IntegerLength[n, 2]] - 1, 0, -1]) * IntegerDigits[n, 2]]; Array[a, 35, 0] (* Amiram Eldar, Oct 31 2022 *)
PROG
(Python)
def a(n):
binary_string = "{0:b}".format(n)[::-1] # little-endian
result = 0
for i, binary_digit in enumerate(binary_string):
if binary_digit == '1':
result += 1 << (1 << i) # 2 ** (2 ** i)
return result
(PARI) a(n) = my(d=Vecrev(digits(n, 2))); for (k=1, #d, d[k] *= 2^(2^(k-1))); vecsum(d); \\ Michel Marcus, Oct 31 2022
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Tilman Piesk, Oct 30 2022
STATUS
approved