login
A366136
Minimal number of factorials or their negatives that add to n.
2
0, 1, 1, 2, 2, 2, 1, 2, 2, 3, 3, 3, 2, 3, 3, 4, 3, 3, 2, 3, 3, 3, 2, 2, 1, 2, 2, 3, 3, 3, 2, 3, 3, 4, 4, 4, 3, 4, 4, 5, 4, 4, 3, 4, 4, 4, 3, 3, 2, 3, 3, 4, 4, 4, 3, 4, 4, 5, 5, 5, 4, 5, 5, 6, 5, 5, 4, 5, 5, 5, 4, 4, 3, 4, 4, 5, 5, 5, 4, 5, 5, 6, 5, 5, 4, 5, 5
OFFSET
0,4
LINKS
EXAMPLE
11 = 6 + 6 - 1 (three factorials), so a(11) = 3.
15 = 6 + 6 + 2 + 1 or 15 = 24 - 6 - 2 - 1 (four factorials), so a(15) = 4.
MATHEMATICA
seq[m_] := Module[{s = Table[m!, {m!}], d, b, sum}, Do[d = PadLeft[Most@ IntegerDigits[k, MixedRadix[Range[m, 1, -1]]], m]; Do[b = 2*PadLeft[ IntegerDigits[i, 2], m] - 1; sum = Total[b * d * Range[m, 1, -1]!]; If[0 < sum <= m!, s[[sum]] = Min[s[[sum]], Total[d]]], {i, 1, 2^m - 1}], {k, 1, 2*m!}]; Join[{0}, s]]; seq[5] (* Amiram Eldar, Oct 03 2023 *)
CROSSREFS
KEYWORD
nonn,look
AUTHOR
James C. McMahon, Sep 30 2023
STATUS
approved