l2l2Ḟ - Link 1: integer, X -> floor(X log 2 log 2)
Note when X = 1 l2l2 -> (-inf + nan j) and Ḟ takes the real part -> -inf
WµÇ2*2*⁸d⁹jɗ×nJaƲ¹Ƈ)F$ÐLÇ»-ị“4HBSI12 - Main Link: positive integer P
W - wrap P in a list
ÐL - apply while distinct:
$ - last two links as a monad - f(Current):
µ ) - for each {V in Current}:
Ç - call Link 1 -> floor(V log 2 log 2)
2* - 2 exponentiate {that}
2* - 2 exponentiate {that}
-> value of the digit to use, say D
⁸ ɗ - last three links as a dyad - f(V, D):
⁹ - D
d - {V} div-mod {D}
j - join {that} with {D}
Ʋ - last four links as a monad - f(Parts=that):
J - indices {Parts} -> [1,2,3]
n - {Parts} not equal {that} (vectorises)
× - {Parts} multiply {that} (vectorises)
a - {that} logical AND {Parts}
¹Ƈ - keep truthy values
F - flatten
Ç - call Link 1 (vectorises)
»- - max with -1 (convert -inf to -1)
ị“4HBSI12 - index into (1-based & modular) "4HBSI12"
- implicit print