cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A050482 Sum of remainders when n-th prime is divided by all preceding integers.

Original entry on oeis.org

0, 1, 4, 8, 22, 28, 51, 64, 98, 151, 167, 233, 297, 325, 403, 505, 635, 645, 790, 904, 923, 1113, 1244, 1422, 1654, 1800, 1888, 2056, 2098, 2256, 2849, 3066, 3326, 3450, 3969, 4045, 4329, 4696, 5014, 5325, 5767, 5759, 6499, 6565, 6898
Offset: 1

Views

Author

Brian Wallace (wallacebrianedward(AT)yahoo.co.uk), Dec 26 1999

Keywords

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]

Examples

			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.
		

Crossrefs

Programs

  • 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 *)
  • 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

Formula

a(n) = A004125(A000040(n)). - R. J. Mathar, Jun 12 2009