%I #11 May 13 2013 01:49:10
%S 0,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,
%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
%N Legendre symbol (n,65537).
%C 65537 is the 4th Fermat prime, A019434(4).
%H A. Karttunen, <a href="/A165471/b165471.txt">Table of n, a(n) for n = 0..65537</a>
%o (MIT Scheme, using fixnum-implementation of jacobi-symbol that works only up to 2^25-1 = 33554431):
%o (define (A165471 n) (legendre-symbol n 65537))
%o (define legendre-symbol jacobi-symbol)
%o (define jacobi-symbol fix:jacobi-symbol)
%o (define (fix:jacobi-symbol p q) (if (not (and (fix:fixnum? p) (fix:fixnum? q) (fix:= 1 (fix:and q 1)))) (error "fix:jacobi-symbol: args must be fixnums, and 2. arg should be odd: " p q) (let loop ((p p) (q q) (s 0)) (cond ((fix:zero? p) 0) ((fix:= 1 p) (fix:- 1 (fix:and s 2))) ((fix:= 1 (fix:and p 1)) (loop (fix:remainder q p) p (fix:xor s (fix:and p q)))) (else (loop (fix:lsh p -1) q (fix:xor s (fix:xor q (fix:lsh q -1)))))))))
%o (PARI) a(n)=kronecker(n,65537) \\ _Charles R Greathouse IV_, Oct 31 2011
%o (Sage)
%o def A165471(n): return legendre_symbol(n,65537)
%o [A165471(n) for n in range(82)] # _Peter Luschny_, Aug 09 2012
%Y Partial sums: A165472.
%K sign,mult,easy
%O 0,1
%A _Antti Karttunen_, Sep 21 2009
|