OFFSET
1,5
COMMENTS
The graph consists of a succession of parallelograms. The parallelograms end when there is a long run of mostly positive terms followed by a long run of mostly negative terms. The places where the successive parallelograms end are the primes just before a power of 2: 3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, ..., which are terms with indices 2, 4, 6, 11, 18, 31, 54, 97, 172, 309, 564, 1028, 1900, 3512, 6542, 12251, 23000, 43390, 82025, ... (see A014234 and A007053). - N. J. A. Sloane, May 29 2016
LINKS
N. J. A. Sloane, Table of n, a(n) for n = 1..23000, May 29 2016 [First 10000 terms from Robert Israel]
Rémy Sigrist, Colored scatterplot of the first 82025 terms (corresponding to the prime numbers < 2^20) (where the color is function of A000040(n) mod 8)
N. J. A. Sloane, Table of n, a(n) for n = 1..78498
N. J. A. Sloane and Brady Haran, Amazing Graphs, Numberphile video (2019)
FORMULA
EXAMPLE
n=5: prime(5) = 11_10 = 1011_2, reversing gives 1101_2 = 13_10, so a(5) = 11-13 = -2.
MAPLE
revdigs:= proc(n) local L, j;
L:= convert(n, base, 2);
add(L[-j]*2^(j-1), j=1..nops(L))
end proc:
map(t -> t - revdigs(t), select(isprime, [2, seq(i, i=3..1000, 2)])); # Robert Israel, Dec 08 2015
MATHEMATICA
Table[# - FromDigits[Reverse@ IntegerDigits[#, 2], 2] &@ Prime@ n, {n, 60}] (* Michael De Vlieger, Dec 09 2015 *)
PROG
(PARI) a098957(n) = my(v=binary(prime(n)), s); forstep(i=#v, 1, -1, s+=s+v[i]); s
a(n) = prime(n) - a098957(n); \\ Altug Alkan, Dec 07 2015
CROSSREFS
KEYWORD
AUTHOR
Max Barrentine, Dec 07 2015
STATUS
approved