public static long syJacobi(long a, long n) {
		long v=n;
		long u=a;
		long s=1; 
		long temp;
		if(u<0) { 
			u=-u; 
			s=(long) Math.pow(-1,(v-1)/2);
		}
		while(u>=2) { 
			if(u%2==0) {
				u/=2; 
				s*=(long) Math.pow(-1,(v*v-1)/8);
			}
			else {
				s*=(long) Math.pow(-1,(v-1)*(u-1)/4);
				temp=v%u; 
				v=u; 
				u=temp; 
			} 
		} 
		if(u==0) {
			s=0 ; 
		}
		return s;
	}