login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Least number of odd primes that add up to n, or 0 if no such representation is possible.
0

%I #14 Nov 28 2020 20:02:53

%S 0,0,1,0,1,2,1,2,3,2,1,2,1,2,3,2,1,2,1,2,3,2,1,2,3,2,3,2,1,2,1,2,3,2,

%T 3,2,1,2,3,2,1,2,1,2,3,2,1,2,3,2,3,2,1,2,3,2,3,2,1,2,1,2,3,2,3,2,1,2,

%U 3,2,1,2,1,2,3,2,3,2,1,2,3,2,1,2,3,2,3,2,1,2,3,2,3,2,3,2,1,2,3,2,1,2,1,2,3,2,1,2,1,2

%N Least number of odd primes that add up to n, or 0 if no such representation is possible.

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/PrimePartition.html">Prime Partition</a>

%H <a href="/index/Go#Goldbach">Index entries for sequences related to Goldbach conjecture</a>

%e a(9) = 3 because 9 = 3 + 3 + 3 is a partition of 9 into 3 odd prime parts and there is no such partition with fewer terms.

%t Block[{f, a}, f[m_] := Block[{s = {Prime@ PrimePi@ m}}, KeySort@ Merge[#, Identity] &@ Reap[Do[If[# <= m, Sow[# -> s]; AppendTo[s, Last@ s], If[Last@ s == 3, s = DeleteCases[s, 3]; If[Length@ s == 0, Break[], s = MapAt[Prime[PrimePi[#] - 1] &, s, -1]], s = MapAt[Prime[PrimePi[#] - 1] &, s, -1]]] &@ Total[s], {i, Infinity}]][[-1, -1]] ]; a = f[105]; Array[If[KeyExistsQ[a, #], Min@ Map[Length, Lookup[a, #]], 0] &, Max@ Keys@ a]] (* _Michael De Vlieger_, Nov 04 2020 *)

%Y Cf. A051034, A065091.

%K nonn

%O 1,6

%A _Ilya Gutkovskiy_, Nov 04 2020