login
a(n) = (-1)^((prime(n) + 1)/2).
2

%I #17 Feb 16 2020 22:01:47

%S 1,-1,1,1,-1,-1,1,1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,-1,-1,-1,1,1,-1,

%T -1,1,1,-1,1,-1,1,-1,1,1,-1,1,-1,1,-1,-1,1,1,1,1,-1,-1,1,-1,1,-1,1,-1,

%U 1,-1,-1,1,-1,1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,-1,1,1,-1,-1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,1,-1

%N a(n) = (-1)^((prime(n) + 1)/2).

%C a(n) = +1 iff prime(n) == 3 (mod 4), a(n) = -1 iff prime(n) == 1 (mod 4), n>=2.

%C If -1 is replaced by 0 this is the characteristic sequence of the primes of the form 4*k+3, k=0,1,2,... See A002145 and A100672(n), n>=2.

%C a(n) = (((prime(n)-1)/2)!)^2 mod prime(n), n>=2. For the proof see a comment on A212158 regarding a corollary to Wilson's theorem. See, e.g., the link with a blog by W. Holsztyński.

%C a(n) is congruent to 1^2*3^2*5^2*...*(prime(n)-2)^2 (mod prime(n)). For example, a(4)=1 because 7 is the 4th prime number and 1^2*3^2*5^2==1 (mod 7). - _Geoffrey Critzer_, Apr 03 2015

%D K. H. Rosen, Elementary Number Theory, Addison-Wesley, 2011, page 223.

%D J. V. Uspensky and M. A. Heaslet, Elementary Number Theory, McGraw-Hill, NY, 1939, p. 156.

%H Holsztyński Włodzimierz, <a href="http://wlod.wordpress.com/article/congruence-x-2-1-mod-p-euler-and-a-1jxfhq4x4sw0j-65/">Congruence x^2==-1 (mod p) (Euler), and a super-Wilson Theorem</a>

%F a(n) = (-1)^((prime(n)+1)/2) = (-1)^A006254(n-1), n>=2.

%F a(n) = (A212158(n))^2 (mod prime(n)), n>=2. See a comment above.

%e a(2) = +1 because (3+1)/2 is even.

%e a(2) = +1 because 1^2 mod 3 = +1.

%e a(6) = -1 because (13+1)/2 = 7, and 7 is odd.

%e a(6) = -1 because 720^2 = 518400 == 12 (mod 13) == -1 (mod 13).

%t Table[(-1)^((p + 1)/2), {p, Prime[Range[2, 100]]}] (* _Geoffrey Critzer_, Apr 03 2015 *)

%o (PARI) a(n)=-(-1)^(prime(n)\2) \\ _Charles R Greathouse IV_, Jun 13 2013

%K sign,easy

%O 2

%A _Wolfdieter Lang_, May 08 2012