login
This site is supported by donations to The OEIS Foundation.
Logo

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; internal format)
OFFSET

1,3

COMMENTS

Only 3d = 11b has an alternating sum of 0.

LINKS

Harry J. Smith, Table of n, a(n) for n=1,...,1000

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) )

} - [From Harry J. Smith (hjsmithh(AT)sbcglobal.net), 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, ", ")) -[W. Bomfim, Jan 16, 2011]

CROSSREFS

Cf. A065359.

Sequence in context: A064693 A072085 A054868 * A196942 A184304 A025909

Adjacent sequences:  A065078 A065079 A065080 * A065082 A065083 A065084

KEYWORD

base,easy,sign

AUTHOR

Robert G. Wilson v (rgwv(AT)rgwv.com), Nov 09 2001

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Transforms | Puzzles | Hot | Classics
Recent Additions | More pages | Superseeker | Maintained by The OEIS Foundation Inc.

Content is available under The OEIS End-User License Agreement .

Last modified February 15 08:20 EST 2012. Contains 205729 sequences.