A048153 a(n) = Sum_{k=1..n} (k^2 mod n).
0, 1, 2, 2, 10, 13, 14, 12, 24, 45, 44, 38, 78, 77, 70, 56, 136, 129, 152, 130, 182, 209, 184, 148, 250, 325, 288, 294, 406, 365, 372, 304, 484, 561, 490, 402, 666, 665, 572, 540, 820, 805, 860, 726, 840, 897, 846, 680, 980, 1125, 1156, 1170, 1378, 1305, 1210
Offset: 1
Keywords
Examples
a(5) = 1^2 + 2^2 + (3^2 mod 5) + (4^2 mod 5) + (5^2 mod 5) = 1 + 4 + 4 + 1 + 0 = 10. (It is easily seen that the last term, n^2 mod n, is always zero and would not need to be included.) - _M. F. Hasler_, Oct 21 2013
Links
- Zak Seidov, Table of n, a(n) for n = 1..10000
Programs
-
Haskell
a048153 = sum . a048152_row -- Reinhard Zumkeller, Apr 29 2013
-
Mathematica
Table[Sum[PowerMod[k,2,n], {k,n-1}], {n,1,10000}] (* Zak Seidov, Nov 02 2011 *)
-
PARI
a(n)=sum(k=1,n,k^2%n) \\ Charles R Greathouse IV, Oct 21 2013
-
Python
def A048153(n): return sum(k**2%n for k in range(1,n)) # Chai Wah Wu, Jun 02 2024
Formula
a(n) == n*(n+1)*(2n+1)/6 (mod n). - Charles R Greathouse IV, Dec 28 2011
a(n) == n*(n-1)*(2n-1)/6 (mod n). - Chai Wah Wu, Jun 02 2024
a(n) mod n = A215573(n). - Alois P. Heinz, Jun 03 2024
Extensions
Definition made more explicit by M. F. Hasler, Oct 21 2013
Comments