login
Primes > 3 for which the alternating bit sum (A065359) is not equal to 1 or 2.
1

%I #10 Mar 02 2015 02:16:26

%S 11,41,43,47,59,107,131,137,139,163,167,173,179,191,227,233,239,251,

%T 277,337,349,373,419,431,443,491,521,523,547,557,563,569,571,587,617,

%U 619,641,643,647,653,659,673,677,683,691,701,719,739,743,751,761,809

%N Primes > 3 for which the alternating bit sum (A065359) is not equal to 1 or 2.

%C Differs from A065049 beginning with 683.

%D William Paulsen, wpaulsen(AT)csm.astate.edu, personal communication.

%H Harry J. Smith, <a href="/A065079/b065079.txt">Table of n, a(n) for n=1,...,1000</a>

%e 11 is in the sequence because 11d = 1011b, so the alternating digits sum of 11 is 1 -1 +0 -1 = -1 which is neither 1 nor 2.

%t Do[d = Reverse[ IntegerDigits[ Prime[n], 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; If[s != 1 && s != 2, Print[ Prime[n]]], {n, 3, 141} ]

%o (PARI) baseE(x, b)= { local(d, e=0, f=1); while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=10); return(e) } SumAD(x)= { local(a=1, s=0); while (x>9, s+=a*(x-10*(x\10)); x\=10; a=-a); return(s + a*x) } { n=0; for (m=3, 10^9, p=prime(m); s=SumAD(baseE(p, 2)); if (s!=1 && s!=2, write("b065079.txt", n++, " ", p); if (n==1000, return)) ) } \\ _Harry J. Smith_, Oct 06 2009

%o (PARI)f(p)={s=0;u=1;for(k=0,#binary(p)-1,s+=bittest(p,k)*u;u=-u);return(s)};forprime(p=5,809,F=f(p);if((F!=1)&&(F!=2),print1(p,", "))) \\ _Washington Bomfim_, Jan 18 2011

%Y Cf. A065049.

%K base,nonn,easy

%O 1,1

%A _Robert G. Wilson v_, Nov 08 2001

%E "> 3" added to definition by _Harry J. Smith_, Oct 06 2009