%I #76 Sep 13 2022 09:33:39
%S 3,4551,46775,82503,106976,1642796,4290771,4492203,4976427,21537831,
%T 21549347,21879936,51127259,56786087,60296571,80837771,87761787,
%U 94424463,96593696,138644871,168864999,221395539,255881451,297460451,305198247,360306363,562654203
%N Numbers n such that n + 2 divides n^n - 2.
%C Numbers n such that (n^n - 2)/(n + 2) is an integer.
%C Since n == -2 (mod n+2), also numbers n such that n + 2 divides (-2)^n - 2. - _Robert Israel_, Jan 04 2015
%C Numbers n == 0 (mod 4) such that A066602(n/2+1) = 8, and odd numbers n such that n = 3 or A082493(n+2) = 8. - _Robert Israel_, Apr 08 2015
%H Max Alekseyev, <a href="/A251603/b251603.txt">Table of n, a(n) for n = 1..890</a> (all terms below 10^15)
%F The even terms form A122711, the odd terms are those in A245319 (forming A357125) decreased by 2. - _Max Alekseyev_, Sep 22 2016
%e 3 is in this sequence because 3 + 2 = 5 divides 3^3 - 2 = 25.
%p isA251603 := proc(n)
%p if modp(n &^ n-2,n+2) = 0 then
%p true;
%p else
%p false;
%p end if;
%p end proc:
%p A251603 := proc(n)
%p option remember;
%p local a;
%p if n = 1 then
%p 3;
%p else
%p for a from procname(n-1)+1 do
%p if isA251603(a) then
%p return a;
%p end if;
%p end do:
%p end if;
%p end proc: # _R. J. Mathar_, Jan 09 2015
%t Select[Range[10^6], Mod[PowerMod[#, #, # + 2] - 2, # + 2] == 0 &] (* _Michael De Vlieger_, Dec 20 2014, based on _Robert G. Wilson v_ at A252041 *)
%o (Magma) [n: n in [0..10000] | Denominator((n^n-2)/(n+2)) eq 1];
%o (PARI) for(n=1,10^9,if(Mod(n,n+2)^n==+2,print1(n,", "))); \\ _Joerg Arndt_, Dec 06 2014
%o (Python) A251603_list = [n for n in range(1,10**6) if pow(n, n, n+2) == 2] # _Chai Wah Wu_, Apr 13 2015
%Y Cf. A001477, A004273, A004275, A066602, A082493, A081765, A213382, A252606, A357125.
%K nonn
%O 1,1
%A _Juri-Stepan Gerasimov_, Dec 05 2014
%E a(6)-a(27) from _Joerg Arndt_, Dec 06 2014
|