(phixonline)-->
with javascript_semantics
function max_power(integer base = 10)
integer m = 1
atom f = factorial(base-1)
while m*f >= power(base,m-1) do
m += 1
end while
return m-1
end function
constant digits = "0123456789abcd"
function fcomb(sequence res, integer base, n, at=1, atom fsum=0, string chosen="")
if length(chosen)=n then
string fs = sort(sprintf("%a",{{base,fsum}}))
if fs=chosen then
res = append(res,sprintf("%d",fsum))
end if
else
for i=at to base do
res = fcomb(res,base,n,i,fsum+factorial(i-1),chosen&digits[i])
end for
end if
return res
end function
function factorions(integer base = 10)
sequence result = {}
for k=1 to max_power(base) do
result &= fcomb({},base,k)
end for
return result
end function
for base=2 to 14 do
printf(1,"Base %2d factorions: %s\n",{base,join(factorions(base))})
end for