login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A072820 Largest number of distinct primes to represent n as arithmetic mean. 2

%I #24 Nov 14 2020 07:08:27

%S 1,1,3,3,5,4,5,5,7,6,9,8,9,9,11,10,11,11,13,12,13,13,15,14,17,15,17,

%T 16,17,17,19,18,19,19,21,20,23,21,23,22,23,23,25,24,25,25,27,26,27,27,

%U 29,28,29,28,29,29,31,30,31,31,33,32,33,33,35,33,35,34,37,35,37,36,37,37

%N Largest number of distinct primes to represent n as arithmetic mean.

%H Alois P. Heinz, <a href="/A072820/b072820.txt">Table of n, a(n) for n = 2..100</a>

%H Reinhard Zumkeller, <a href="/A072701/a072701.txt">Representing integers as arithmetic means of primes</a>

%e a(20) = 13: (2+3+5+7+11+13+17+19+23+29+31+41+59)/13 = 20. [corrected by _Jean-François Alcover_, Nov 10 2020]

%p sp:= proc(i) option remember; `if`(i=1, 2, sp(i-1) +ithprime(i)) end:

%p b:= proc(n, i, t) 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, 1, 0) else h := b(n, prevprime(i), t); b(n, i, t):= `if`(h>0, h, b(n-i, prevprime(i), t-1)) fi end:

%p a:= proc(n) local i, k; if n<4 then 1 else for k from 2 while sp(k)/k<=n do od: do k:= k-1; if b(k*n, nextprime(k*n -sp(k-1)-1), k)>0 then break fi od; k fi end: seq(a(n), n=2..50); # _Alois P. Heinz_, Aug 03 2009

%t sp[i_] := sp[i] = If[i == 1, 2, sp[i - 1] + Prime[i]];

%t b[n_, i_, t_] := b[n, i, t] = Module[{h}, Which[n < 0, 0, n == 0, If[t == 0, 1, 0], i == 2, If[n == 2 && t == 1, 1, 0], True, h = b[n, NextPrime[i, -1], t]; If[h > 0, h, b[n - i, NextPrime[i, -1], t - 1]]]];

%t a[n_] := a[n] = Module[{k}, If[n < 4, 1, For[k = 2, sp[k]/k <= n, k++]; While[True, k = k - 1; If[b[k n, NextPrime[k n - sp[k - 1] - 1], k] > 0, Break[]]]; k]];

%t Table[Print[n, " ", a[n]]; a[n], {n, 2, 100}] (* _Jean-François Alcover_, Nov 13 2020, after _Alois P. Heinz_ *)

%Y Cf. A072701.

%K nonn

%O 2,3

%A _Reinhard Zumkeller_, Jul 15 2002

%E More terms from _Alois P. Heinz_, Aug 03 2009

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 18 15:07 EDT 2024. Contains 375269 sequences. (Running on oeis4.)