OFFSET
1,2
COMMENTS
Conjecture: Every nonnegative integer can appear in the sequence at most finitely many times. - Thomas Ordowski, Jul 22 2013
I conjecture the opposite. Heuristically a given number should appear log log x times below x. - Charles R Greathouse IV, Jul 22 2013
In the first 10000 terms, one sees a(n) = n for n=2,7,12. Does this ever happen again? - J. M. Bergot, Mar 26 2018
Yes, it happens for n = 83408, too. - Michel Marcus, Mar 27 2018
LINKS
T. D. Noe, Table of n, a(n) for n = 1..10000
FORMULA
a(n) = s[n] - p[n]*q[n], where s[n] = sum of first n primes, p[n] is n-th prime and q[n] is floor(s[n]/p[n]).
a(A024011(n)) = 0. - Michel Marcus, Jan 22 2015
EXAMPLE
a[5] = 6 because s[5] = 2+3+5+7+11 = 28, p[5]=11 and q[5]= floor(28/11)=2, so a[5] = 28-11*2 = 6.
MAPLE
s:= proc(n) option remember; `if`(n=0, 0, ithprime(n)+s(n-1)) end:
a:= n-> irem(s(n), ithprime(n)):
seq(a(n), n=1..100); # Alois P. Heinz, Mar 27 2018
MATHEMATICA
f[n_] := Mod[ Sum[ Prime[i], {i, 1, n - 1}], Prime[n]]; Table[ f[n], {n, 1, 70}] or
a[1] = 0; a[n_] := Block[{s = Sum[Prime[i], {i, 1, n}]}, s - Prime[n]*Floor[s/Prime[n]]]; Table[ f[n], {n, 1, 70}]
f[n_] := Mod[Plus @@ Prime@ Range@ n, Prime@ n]; Array[f, 70] (* Robert G. Wilson v, Nov 12 2016 *)
Module[{nn=70, t}, t=Accumulate[Prime[Range[nn]]]; Mod[#[[1]], #[[2]]]&/@ Thread[ {t, Prime[Range[nn]]}]] (* Harvey P. Dale, Sep 19 2019 *)
PROG
(PARI) for(n=1, 100, s=sum(i=1, n, prime(i)); print1(s-prime(n)*floor(s/prime(n)), ", "))
(PARI) a(n) = vecsum(primes(n)) % prime(n); \\ Michel Marcus, Mar 27 2018
(GAP) P:=Filtered([1..1000], IsPrime);
a:=List([1..70], i->Sum(P{[1..i]}) mod P[i]); # Muniru A Asiru, Mar 27 2018
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Randy L. Ekl, May 26 2002
EXTENSIONS
Edited by Robert G. Wilson v and Benoit Cloitre, May 30 2002
STATUS
approved