A336823 a(1)=1; thereafter a(n) = a(n-1) / wt(n-1) if wt(n-1) divides a(n-1), otherwise a(n) = a(n-1) * wt(n-1) where wt(n) is the binary weight of n.
1, 1, 1, 2, 2, 1, 2, 6, 6, 3, 6, 2, 1, 3, 1, 4, 4, 2, 1, 3, 6, 2, 6, 24, 12, 4, 12, 3, 1, 4, 1, 5, 5, 10, 5, 15, 30, 10, 30, 120, 60, 20, 60, 15, 5, 20, 5, 1, 2, 6, 2, 8, 24, 6, 24, 120, 40, 10, 40, 8, 2, 10, 2, 12, 12, 6, 3, 1, 2, 6, 2, 8, 4, 12, 4, 1, 3, 12
Offset: 1
Examples
a(1)=1 is given, and has 1, the binary weight of 1, as a factor so a(2) =1/1=1; a(2)=1 which has 1, the binary weight of 2, as a factor so a(3) =1/1=1; a(3)=1 which does not have 2, the binary weight of 3, as a factor so a(4) =1*2=2.
Links
- Gage Schacher, Table of n, a(n) for n = 1..10000
Programs
-
Mathematica
a[1] = 1; a[n_] := a[n] = If[Divisible[a[n-1], (w = DigitCount[n-1, 2, 1])], a[n-1] / w, a[n-1] * w]; Array[a, 100] (* Amiram Eldar, Aug 05 2020 *)
-
PARI
a(n) = if (n==1, 1, my(h=hammingweight(n-1), last=a(n-1)); if (last%h, last*h, last/h)); \\ Michel Marcus, Aug 05 2020
Formula
Extensions
a(1)=1 added to definition. - N. J. A. Sloane, Sep 21 2020