[go: up one dir, main page]

login
If 2^(n-1) mod n = 1, then 1 else 0.
3

%I #29 Sep 20 2017 11:27:22

%S 0,0,1,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,

%T 0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0,1,0,0,0,0,0,1,0,

%U 0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0

%N If 2^(n-1) mod n = 1, then 1 else 0.

%C This first differs from A010051 (1 if n is prime, else 0) at the second term. The next position differing from A010051 is at the 341st term, and further divergences appear for odd pseudoprimes to base 2 (A001567).

%H Antti Karttunen, <a href="/A257531/b257531.txt">Table of n, a(n) for n = 1..68101</a>

%H <a href="/index/Ch#char_fns">Index entries for characteristic functions</a>

%e a(341) = 1 as 2^340 mod 341 is 1.

%p [0, seq(`if`(2 &^ (n-1) mod n = 1, 1, 0), n = 2..104)]; # _Peter Luschny_, Sep 19 2017

%t f[n_] := If[PowerMod[2, n - 1, n] == 1, 1, 0]; Array[f, 105] (* _Robert G. Wilson v_, Apr 28 2015 *)

%o (PARI) A257531(n) = if(n==1, 0, if(Mod(2, n)^(n-1)==1, 1, 0)); \\ _Antti Karttunen_, _Michel Marcus_ & _Altug Alkan_, Sep 13-20 2017

%Y Characteristic function for A176997 (without its initial 1).

%Y Cf. A001567, A010051, A062173.

%K nonn

%O 1

%A _Gerald Hillier_, Apr 28 2015