login
a(n) is the smallest positive k such that -n^n == n (mod n + k).
1

%I #22 Aug 13 2024 02:22:37

%S 1,1,2,1,5,1,3,1,9,1,11,1,13,1,14,1,17,1,7,1,21,1,23,1,25,1,3,1,29,1,

%T 6,1,33,1,35,1,37,1,39,1,41,1,7,1,45,1,18,1,49,1,50,1,53,1,19,1,45,1,

%U 59,1,61,1,7,1,65,1,63,1,44,1,71,1,40,1,12,1,12,1,27,1,81,1,23,1,85,1,58,1,8,1,6,1,9

%N a(n) is the smallest positive k such that -n^n == n (mod n + k).

%F a(n) = 1 for n even and a(n) <= n for n odd. - _Michael S. Branicky_, Jul 28 2024

%F a(n) + n is the least divisor > n of n^n + n. - _Robert Israel_, Jul 30 2024

%p f:= proc(n) local k;

%p for k from 1 do if n &^ n + n mod (n+k) = 0 then return k fi od

%p end proc:

%p map(f, [$1..100]); # _Robert Israel_, Jul 30 2024

%t a[n_] := Module[{k = 1}, While[PowerMod[n, n, n + k] != k, k++]; k]; Array[a, 100] (* _Amiram Eldar_, Jul 26 2024 *)

%o (Python)

%o def a(n): return next(k for k in range(1, n+1) if pow(n, n, n+k) == k)

%o print([a(n) for n in range(1, 94)]) # _Michael S. Branicky_, Jul 26 2024

%o (Python)

%o from itertools import count

%o def A374964(n):

%o m = n**n+n

%o return next(d for d in count(1) if not m%(n+d)) # _Chai Wah Wu_, Aug 12 2024

%o (PARI) a(n) = my(k=1); while (-Mod(n, n+k)^n != n, k++); k; \\ _Michel Marcus_, Jul 26 2024

%Y Cf. A066068 (n^n+n).

%K nonn

%O 1,3

%A _Juri-Stepan Gerasimov_, Jul 25 2024