OFFSET
0,7
COMMENTS
Because A292590(n) = a(A245611(n)), the sequence works as a "masking function" where the 1-bits in a(n) (always a subset of the 1-bits in binary expansion of n) indicate which numbers are multiples of 3 in binary tree A245612 on that trajectory which leads from the root of the tree to the node containing A245612(n). See the examples.
LINKS
FORMULA
EXAMPLE
A245612(18) = 188, that is, at "node address" 18 in binary tree A245612 sits number 188. 18 in binary is "10010", which when read from left to right (after the most significant bit which is always 1) gives the directions to follow in the tree when starting from the root, to land in node containing number 188. Here, after 1 and 2, turn left from 2, turn left from 5, turn right from 14 and then turn left from 63 and then indeed one lands in 188. These turns correspond with the four lowermost bits of the code, "0010". When one selects multiples of 3 from this path 1 -> 2 -> 5 -> 14 -> 63 -> 188, the only one is 63, which corresponds with the second rightmost bit (which also is the only 1-bit) in the code, which can be masked with 2 (binary "10"), thus a(18) = 2.
A245612(15) = 6, that is, at "node address" 15 in binary tree A245612 sits number 6. 15 in binary is "1111", which tells that 6 can be located in tree A245612 by going (after the initial root 1 and 2) three steps towards right from 2: 1 -> 2 -> 3 -> 4 -> 6. Of these numbers, only 3 and 6 are multiples of 3, thus the mask to obtain the corresponding bits from "1111" is "00101" (5 in binary), thus a(15) = 5.
A245612(31) = 7, that is, at "node address" 31 in binary tree A245612 sits number 7. 31 in binary is "11111", which tells that 7 can be located in tree A245612 by going (after the initial root 1 and 2) four steps towards right from 2: 1 -> 2 -> 3 -> 4 -> 6 -> 7. Of these numbers, only 3 and 6 are multiples of 3, thus the mask to obtain the corresponding bits from "11111" is "001010" (ten in binary), thus a(31) = 10.
MATHEMATICA
f[n_] := f[n] = Which[n == 1, 0, Mod[n, 3] == 2, Ceiling[n/3], True, (Times @@ Power[If[# == 1, 1, NextPrime[#, -1]] & /@ First@ #, Last@ #] &@ Transpose@ FactorInteger[2 n - 1] + 1)/2]; g[n_] := g[n] = If[n == 1, 0, 2 g[f@ n] + Boole[Divisible[n, 3]]]; h[n_] := (Times @@ Power[If[# == 1, 1, NextPrime@ #] & /@ First@ #, Last@ #] + 1)/2 &@ Transpose@ FactorInteger@If[n == 0, 1, Prime[#] Product[ Prime[m]^(Map[ Ceiling[(Length@ # - 1)/2] &, DeleteCases[ Split@ Join[ Riffle[ IntegerDigits[n, 2], 0], {0}], {k__} /; k == 1]][[-m]]), {m, #}] &[DigitCount[n, 2, 1]]]; Array[g@ h@ # &, 108, 0] (* Michael De Vlieger, Sep 22 2017 *)
CROSSREFS
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Sep 20 2017
STATUS
approved