cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A366136 Minimal number of factorials or their negatives that add to n.

This page as a plain text file.
%I A366136 #18 Jan 23 2024 11:06:01
%S A366136 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,
%T A366136 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,
%U A366136 5,5,4,4,3,4,4,5,5,5,4,5,5,6,5,5,4,5,5
%N A366136 Minimal number of factorials or their negatives that add to n.
%H A366136 Alois P. Heinz, <a href="/A366136/b366136.txt">Table of n, a(n) for n = 0..10000</a>
%e A366136 11 = 6 + 6 - 1 (three factorials), so a(11) = 3.
%e A366136 15 = 6 + 6 + 2 + 1 or 15 = 24 - 6 - 2 - 1 (four factorials), so a(15) = 4.
%t A366136 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 *)
%Y A366136 Cf. A000142, A034968, A366693.
%K A366136 nonn,look
%O A366136 0,4
%A A366136 _James C. McMahon_, Sep 30 2023