A385314 a(n) is the least positive integer m such that Sum_{k = 1 .. m} k^n is divisible by n.
1, 3, 2, 7, 4, 4, 6, 15, 2, 4, 10, 8, 12, 3, 5, 31, 16, 27, 18, 24, 6, 11, 22, 31, 4, 12, 2, 7, 28, 4, 30, 63, 11, 8, 14, 40, 36, 19, 12, 31, 40, 8, 42, 16, 5, 11, 46, 31, 6, 4, 17, 32, 52, 40, 10, 31, 18, 28, 58, 31, 60, 15, 6, 127, 4, 27, 66, 8, 23, 7, 70, 80, 72, 36, 5, 47, 6, 36, 78, 31, 2
Offset: 1
Keywords
Examples
a(3) = 2 because 1^3 + 2^3 = 9 is divisible by 3, while 1^3 is not.
Links
- Robert Israel, Table of n, a(n) for n = 1..10000
Programs
-
Maple
f:= proc(n) local k,t; t:= 0: for k from 1 do t:= t + k &^ n mod n; if t = 0 then return k fi; od: end proc: map(f, [$1..100]);
-
Mathematica
a[n_]:=Module[{m=1},While[!Divisible[Sum[k^n,{k,1,m}],n],m++];m];Array[a,81] (* James C. McMahon, Jun 25 2025 *)
-
PARI
a(n) = my(m=1); while(sum(k=1, m, k^n) % n, m++); m; \\ Michel Marcus, Jun 25 2025
Comments