%I #42 May 17 2023 16:44:03
%S 0,0,1,0,1,2,1,0,4,2,1,8,1,2,4,0,1,14,1,8,4,2,1,8,16,2,13,8,1,2,1,0,4,
%T 2,9,32,1,2,4,8,1,32,1,8,31,2,1,32,15,12,4,8,1,14,49,16,4,2,1,8,1,2,4,
%U 0,16,32,1,8,4,22,1,32,1,2,34,8,9,32,1,48,40,2,1,32,16,2,4,40,1,32,64,8,4,2,54,32,1,58,58,88,1,32,1,24,46
%N a(n) = 2^(n-1) mod n.
%C If p is an odd prime then a(p)=1. However, a(n) is also 1 for pseudoprimes to base 2 such as 341.
%H Antti Karttunen, <a href="/A062173/b062173.txt">Table of n, a(n) for n = 1..101101</a> (first 1000 terms from Harry J. Smith)
%H <a href="/index/Ps#pseudoprimes">Index entries for sequences related to pseudoprimes</a>
%F a(n) = A106262(2*n-3, n-2). - _G. C. Greubel_, Jan 11 2023
%e a(5) = 2^(5-1) mod 5 = 16 mod 5 = 1.
%t Array[Mod[2^(# - 1), #] &, 105] (* _Michael De Vlieger_, Jul 01 2018 *)
%t Array[PowerMod[2,#-1,#]&,120] (* _Harvey P. Dale_, May 17 2023 *)
%o (PARI) A062173(n) = if(1==n, 0, lift(Mod(2, n)^(n-1))); \\ _Antti Karttunen_, Jul 01 2018
%o (Haskell)
%o import Math.NumberTheory.Moduli (powerMod)
%o a062173 n = powerMod 2 (n - 1) n -- _Reinhard Zumkeller_, Oct 17 2015
%o (Magma) [Modexp(2,n-1,n): n in [1..110]]; // _G. C. Greubel_, Jan 11 2023
%o (SageMath) [power_mod(2,n-1,n) for n in range(1,110)] # _G. C. Greubel_, Jan 11 2023
%Y Cf. A000079, A001567, A015910, A015919, A062172.
%Y Cf. A082495, A106262, A257531, A305890.
%Y Cf. A176997 (after the initial term, gives the positions of ones).
%K nonn
%O 1,6
%A _Henry Bottomley_, Jun 12 2001
%E More terms from _Antti Karttunen_, Jul 01 2018
|