OFFSET
1,3
COMMENTS
a(n)/(n*log(n))^2 appears to approach a constant ~0.22... for large n. - Benedict W. J. Irwin, Dec 07 2016
Irwin's comment is incorrect. - Bill McEachen, Feb 04 2024. [Indeed, according to the first formula in A004125, a(n)/(n*log(n))^2 approaches a constant, which is not 0.22 but 1-Pi^2/12 = 0.1775... - Amiram Eldar, Feb 04 2024]
LINKS
Charles R Greathouse IV, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
a(4) = 8 because remainders when 7 is divided by 1..6 are 0,1,1,3,2,1, which add to 8.
a(2) = 3 mod (3-1) = 1.
a(3) = (5 mod (5-1)) + (5 mod (5-2)) + (5 mod (5-3)) = 2 + 1 + 1 = 4.
MAPLE
A050482 := proc(n) local a, i; a := 0; for i from 1 to ithprime(n)-1 do a := a+(ithprime(n) mod i); od: end;
MATHEMATICA
Table[Sum[Mod[Prime[n], k], {k, Prime[n]-1}], {n, 45}] (* James C. McMahon, Feb 08 2024 *)
PROG
(PARI) a(n)=my(p=prime(n)); sum(k=2, p, p%k) \\ Charles R Greathouse IV, Jun 03 2013
(Python)
from math import isqrt
from sympy import prime
def A050482(n): return (p:=prime(n))**2+((s:=isqrt(p))**2*(s+1)-sum((q:=p//k)*((k<<1)+q+1) for k in range(1, s+1))>>1) # Chai Wah Wu, Nov 01 2023
CROSSREFS
KEYWORD
nonn
AUTHOR
Brian Wallace (wallacebrianedward(AT)yahoo.co.uk), Dec 26 1999
STATUS
approved