Thursday, May 9, 2024

A366693 Contribution to the OEIS

 

A366693Minimal number of primorials or their negatives that add to n.2
0, 1, 1, 2, 2, 2, 1, 2, 2, 3, 3, 3, 2, 3, 3, 4, 4, 4, 3, 4, 4, 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, 5, 5, 4, 5, 5, 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, 6, 6, 5, 6, 6, 6, 5, 5, 4, 5, 5, 5 (listgraphrefslistenhistoryedittextinternal format)
OFFSET
0,4
LINKS
EXAMPLE
5 = 6 - 1 (two primorials), so a(5) = 2.
27 = 30 - 2 - 1 (three primorials), so a(27) = 3.
MATHEMATICA
a[nthPrimorials_Integer?NonNegative (* Increase nthPrimorials to use more positive and negative primorials in sum *), numberOfPrimorials_Integer?NonNegative (* Increase numberOfPrimorials to increase cap of minimal number of primorials *)] := a[nthPrimorials, numberOfPrimorials] = Module[{A002110, f, h, s}, A002110[nthPrimorials] = Join[{1}, Denominator[Accumulate[1/Prime[Range[nthPrimorials]]]]]; A002110[n_] := A002110[n] = Join[{1}, Denominator[Accumulate[1/Prime[Range[n]]]]]; f[n_] := f[n] = Flatten[Table[p*r, {p, A002110[n - 1]}, {r, {1, -1}}]]; h[n_, u_] := h[n, u] = Sort[Select[DeleteDuplicates[Flatten[Table[Sum[p[j], {j, 1, u}], ##] & @@ Table[{p[j], f[n]}, {j, 1, u}]]], # > 0 &]]; s = Table[Infinity, {A002110[nthPrimorials][[-1]]}]; Monitor[Do[If[s[[k]] > k, s[[k]] = l], {l, 1, numberOfPrimorials}, {k, h[nthPrimorials, l]}], {l, k}]; s = Join[{0}, s]; If[MemberQ[s, Infinity], s[[1 ;; Position[s, Infinity][[1, 1]] - 1]], s]]; a[6, 6] (* Robert P. P. McKone, Oct 21 2023 *)
CROSSREFS
Sequence in context: A261915 A109037 A366136 * A147680 A192895 A210685
KEYWORD
nonn,look
AUTHOR
James C. McMahon, Oct 16 2023
STATUS
approved

No comments:

Post a Comment

An Open Message to the Blog's Fans in Singapore

(Image:  Free 12 singapore icons - Iconfinder ) This past week, more views of this blog were made from Singapore than other country. To ackn...

Popular in last 30 days