OFFSET
2,3
COMMENTS
Thanks to John W. Layman for inspiration.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 2..100
Reinhard Zumkeller, Representing integers as arithmetic means of primes
EXAMPLE
a(6) = 13, as 13 is the largest prime in 6 = (5+7)/2 = (2+3+13)/3 = (2+5+11)/3 = (2+3+5+7+13)/5.
MAPLE
sp:= proc(i) option remember; `if` (i=1, 2, sp(i-1) +ithprime(i)) end:
b:= proc(n, i, t) option remember; local h; if n<0 then 0 elif n=0 then `if` (t=0, 1, 0) elif i=2 then `if` (n=2 and t=1, 2, 0) else `if` (b(n-i, prevprime(i), t-1)>0, i, b(n, prevprime(i), t)) fi end:
a:= proc(n) local s, k; s:= 1; for k from 2 while sp(k)/k<=n do s:= max (s, b(k*n, nextprime (k*n -sp(k-1)-1), k)) od: s end:
seq(a(n), n=2..40); # Alois P. Heinz, Aug 03 2009
MATHEMATICA
sp[i_] := sp[i] = If[i == 1, 2, sp[i - 1] + Prime[i]];
b[n_, i_, t_] := b[n, i, t] = Which[n < 0, 0, n == 0, If[t == 0, 1, 0], i == 2, If[n == 2 && t == 1, 1, 0], True, If[b[n - i, NextPrime[i, -1], t - 1] > 0, i, b[n, NextPrime[i, -1], t]]];
a[n_] := Module[{s, k}, s = 1; For[k = 2, sp[k]/k <= n, k++, s = Max[s, b[k*n, NextPrime[k*n - sp[k - 1] - 1], k]]]; s];
Table[a[n], {n, 2, 60}] (* Jean-François Alcover, Feb 13 2018, after Alois P. Heinz *)
CROSSREFS
KEYWORD
nonn
AUTHOR
Reinhard Zumkeller, Jul 15 2002
EXTENSIONS
More terms from Alois P. Heinz, Aug 03 2009
STATUS
approved