This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A065081 #22 Jul 20 2024 12:50:07 %S A065081 -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, %T A065081 -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, %U A065081 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 %N A065081 Alternating bit sum (A065359) for n-th prime p: replace 2^k with (-1)^k in binary expansion of p. %C A065081 Only 3d = 11b has an alternating sum of 0. %H A065081 Harry J. Smith, <a href="/A065081/b065081.txt">Table of n, a(n) for n=1..1000</a> %H A065081 William Paulsen, wpaulsen(AT)csm.astate.edu, <a href="http://www.csm.astate.edu/~wpaulsen/primemaze/mazepart.html">Partitioning the [prime] maze</a> %e A065081 The sixth prime is 13d = 1101b -> -(1)+(1)-(0)+(1) = 1 = a(6) %t A065081 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} ] %o A065081 (PARI) %o A065081 baseE(x, b)= %o A065081 { %o A065081 local(d, e=0, f=1); %o A065081 while (x>0, d=x-b*(x\b); x\=b; e+=d*f; f*=10); %o A065081 return(e) %o A065081 } %o A065081 SumAD(x)= %o A065081 { %o A065081 local(a=1, s=0); %o A065081 while (x>9, s+=a*(x-10*(x\10)); x\=10; a=-a); %o A065081 return(s + a*x) %o A065081 } %o A065081 { for (n=1, 1000, p=prime(n); %o A065081 s=SumAD(baseE(p, 2)); write("b065081.txt", n, " ", s) ) %o A065081 } \\ _Harry J. Smith_, Oct 06 2009 %o A065081 (PARI) %o A065081 f(p)= %o A065081 { %o A065081 v=binary(p); %o A065081 L=#v; u=1; s=0; %o A065081 forstep(k=L,1,-1, if(v[k]==1,s+=u); u=-u;); %o A065081 return(s) %o A065081 }; %o A065081 for(n=1,100,p=prime(n); an=f(p);print1(an,", ")) \\ _Washington Bomfim_, Jan 16 2011 %o A065081 (Python) %o A065081 from sympy.ntheory import digits, prime %o A065081 def A065081(n): return sum((0,1,-1,0)[i] for i in digits(prime(n),4)[1:]) # _Chai Wah Wu_, Jul 19 2024 %Y A065081 Cf. A065359. %K A065081 base,easy,sign %O A065081 1,3 %A A065081 _Robert G. Wilson v_, Nov 09 2001