Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).
%I #15 Jan 13 2021 04:20:42
%S 4,6,2,1,4,14,2,1,1,9,2,1,4,6,2,1,2,1,2,1,4,3,2,1,1,2,1,1,4,3,2,1,4,9,
%T 2,1,4,4,2,1,4,20,2,1,1,9,2,1,1,1,2,1,2,1,2,1,4,5,2,1,4,2,1,1,4,25,2,
%U 1,4,4,2,1,4,2,1,1,4,7,2,1,1,4,2,1,4,6,2,1,2,1,2,1,4,9,2,1,2,1,1,1,4,20,2,1
%N Smallest k such that n + n^2 + ... + n^k is not squarefree.
%H Amiram Eldar, <a href="/A124259/b124259.txt">Table of n, a(n) for n = 1..1589</a>
%F A124260(n) = Sum_{k=1..a(n)} n^k.
%F a(A013929(n)) = 1.
%e n=5: 5 = A005117(4),
%e 5 + 5^2 = 30 = 2*3*5 = A005117(19),
%e 5 + 5^2 + 5^3 = 155 = 5*31 = A005117(95),
%e 5 + 5^2 + 5^3 + 5^4 = 780 = (2^2)*3*5*13 not squarefree,
%e therefore a(5) = 4 and A124260(5) = 780.
%p A124259 := proc(n)
%p local k ;
%p if n =1 then
%p return 4;
%p end if;
%p for k from 1 do
%p if not numtheory[issqrfree](n*(n^k-1)/(n-1)) then
%p return k;
%p end if
%p end do:
%p end proc:
%p seq(A124259(n),n=1..40) ; # _R. J. Mathar_, Jan 13 2021
%t a[n_] := Module[{k = 1, s = n}, While[SquareFreeQ[s], k++; s += n^k]; k]; Array[a, 100] (* _Amiram Eldar_, Dec 26 2020 *)
%o (PARI) a(n) = my(k=1); while (issquarefree(sum(i=1, k, n^i)), k++); k; \\ _Michel Marcus_, Dec 26 2020
%Y Cf. A005117, A013929, A124260.
%K nonn
%O 1,1
%A _Reinhard Zumkeller_, Oct 23 2006
%E Data corrected by _Amiram Eldar_, Dec 26 2020