OFFSET
0,4
COMMENTS
The variant where the least significant bit has position 1 corresponds to A096111 (with an appropriate offset).
LINKS
Rémy Sigrist, Table of n, a(n) for n = 0..16384
FORMULA
a(2*n) = a(n).
a(2^k) = 1 for any k >= 0.
a(2^k-1) = k! for any k >= 0.
a(2^k+1) = k+1 for any k >= 0.
EXAMPLE
The first terms, alongside the positions of ones and the binary representation of n, are:
n a(n) Pos. ones bin(n)
-- ---- --------- ------
0 1 {} 0
1 1 {1} 1
2 1 {1} 10
3 2 {1,2} 11
4 1 {1} 100
5 3 {1,3} 101
6 2 {1,2} 110
7 6 {1,2,3} 111
8 1 {1} 1000
9 4 {1,4} 1001
10 3 {1,3} 1010
11 12 {1,3,4} 1011
12 2 {1,2} 1100
13 8 {1,2,4} 1101
14 6 {1,2,3} 1110
15 24 {1,2,3,4} 1111
16 1 {1} 10000
MATHEMATICA
A306286[n_] := Times @@ Flatten[Position[IntegerDigits[n, 2], 1]];
Array[A306286, 100, 0] (* Paolo Xausa, Jun 01 2024 *)
PROG
(PARI) a(n) = my (b=binary(n)); prod(k=1, #b, if (b[k], k, 1))
(PARI) a(n) = vecprod(Vec(select(x->(x==1), binary(n), 1))); \\ Michel Marcus, Jun 01 2024
(Python)
from math import prod
def a(n): return prod(i for i, bi in enumerate(bin(n)[2:], 1) if bi == "1")
print([a(n) for n in range(71)]) # Michael S. Branicky, Jun 01 2024
CROSSREFS
KEYWORD
nonn,base,easy
AUTHOR
Rémy Sigrist, May 04 2019
STATUS
approved