login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 60th year, we have over 367,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

Other ways to Give
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A065081 Alternating bit sum (A065359) for n-th prime p: replace 2^k with (-1)^k in binary expansion of p. 2
-1, 0, 2, 1, -1, 1, 2, 1, 2, 2, 1, 1, -1, -2, -1, 2, -1, 1, 1, 2, 1, 1, 2, 2, 1, 2, 1, -1, 1, 2, 1, -1, -1, -2, 2, 1, 1, -2, -1, -1, -1, 1, -1, 1, 2, 1, 1, 1, -1, 1, -1, -1, 1, -1, 2, 2, 2, 1, 4, 2, 1, 2, 1, 2, 1, 2, 1, 4, 2, 4, 2, 2, 1, 4, 1, 2, 2, 1, 2, 1, -1, 1, -1, 1, 1, -1, 2, 1, 2, 1, 2, 2, 1, -1, 1, 2, 2, -1, -2, 1 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,3
COMMENTS
Only 3d = 11b has an alternating sum of 0.
LINKS
William Paulsen, wpaulsen(AT)csm.astate.edu, Partitioning the [prime] maze
EXAMPLE
The sixth prime is 13d = 1101b -> -(1)+(1)-(0)+(1) = 1 = a(6)
MATHEMATICA
f[n_] := (d = Reverse[ IntegerDigits[n, 2]]; l = Length[d]; s = 0; k = 1; While[k < l + 1, s = s - (-1)^k*d[[k]]; k++ ]; s); Table[ Prime[ f[n]], {n, 1, 100} ]
PROG
(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)
}
{ for (n=1, 1000, p=prime(n);
s=SumAD(baseE(p, 2)); write("b065081.txt", n, " ", s) )
} - \\ Harry J. Smith, Oct 06 2009
(PARI)
f(p)=
{
v=binary(p);
L=#v; u=1; s=0;
forstep(k=L, 1, -1, if(v[k]==1, s+=u); u=-u; );
return(s)
};
for(n=1, 100, p=prime(n); an=f(p); print1(an, ", ")) \\ Washington Bomfim, Jan 16 2011
CROSSREFS
Cf. A065359.
Sequence in context: A054868 A352517 A347981 * A366643 A212185 A270928
KEYWORD
base,easy,sign
AUTHOR
Robert G. Wilson v, Nov 09 2001
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified December 7 11:41 EST 2023. Contains 367656 sequences. (Running on oeis4.)