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

 

Logo


Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A308430 Number of 0's minus number of 1's among the edge truncated binary representations of the first n prime numbers. 1
0, 0, 1, 0, 0, 0, 3, 4, 3, 2, -1, 1, 3, 3, 1, 1, -1, -3, 0, 1, 4, 3, 4, 5, 8, 9, 8, 7, 6, 7, 2, 6, 10, 12, 14, 14, 14, 16, 16, 16, 16, 16, 12, 16, 18, 18, 18, 14, 14, 14, 14, 10, 10, 6, 13, 16, 19, 20, 23, 26, 27, 30, 31, 30, 31, 30, 31, 34, 33, 32, 35, 34, 31, 30, 27, 22, 25, 26, 29, 30, 31, 32, 29, 30, 27, 24, 27, 28, 27, 24, 23, 18, 15, 12, 9, 4, -1, 5, 9, 11 (list; graph; refs; listen; history; text; internal format)
OFFSET

1,7

COMMENTS

By "edge truncated" we mean removing the first and last digit. For prime(3)=5 which has binary representation 101 edge truncating yields the string '0'. If there are 2 digits, then edge truncation yields the empty string ''. We count zero 1's and zero 0's in the empty string. The only cases of this are prime(1)=2 and prime(2)=3 which have binary representations 10 and 11.

LINKS

Rémy Sigrist, Table of n, a(n) for n = 1..12251

Sean A. Irvine, Java program (github)

Jonas K. Sønsteby, Graph of 200 terms.

Jonas K. Sønsteby, Graph of 1000 terms.

Jonas K. Sønsteby, Graph of 5000 terms.

Jonas K. Sønsteby, Graph of 10000 terms.

Jonas K. Sønsteby, Graph of 100000 terms.

FORMULA

a(n) = a(n-1) + bitlength(prime(n)_2) - 2 * popcount(prime(n)_2) + 2, n > 1. - Sean A. Irvine, May 27 2019

a(n) = Sum_{k=2..n} (A035100(k) - 2*A014499(k) + 2) = Sum_{k=2..n} (A070939(A000040(k)) - 2*A000120(A000040(k)) + 2). - Daniel Suteu, Jul 13 2019

PROG

(Python 3)

import gmpy2

def dec2bin(x):

    return str(bin(x))[2:]

def digitBalance(string):

    s = 0

    for char in string:

        if int(char) > 0:

            s -= 1

        else:

            s += 1

    return s

N = 100 # number of terms

seq = [0]

prime = 2

for i in range(N-1):

    prime = gmpy2.next_prime(prime)

    binary = dec2bin(prime)

    truncated = binary[1:-1]

    term = seq[-1] + digitBalance(truncated)

    seq.append(term)

print(seq) # Jonas K. Sønsteby, May 27 2019

(PARI) s=0; forprime (p=2, 541, print1 (s += #binary(p\2)+1-2*hammingweight(p\2) ", ")) \\ Rémy Sigrist, Jul 13 2019

(Sage)

def A308430list(b):

    L = []; s = 0

    for p in prime_range(2, b):

        q = (p//2).digits(2)

        s += 1 + len(q) - 2*sum(q)

        L.append(s)

    return L

print(A308430list(542)) # Peter Luschny, Jul 13 2019

CROSSREFS

Cf. A004676, A095375, A014499, A177718, A296062.

Sequence in context: A201935 A225445 A167877 * A280136 A258451 A164358

Adjacent sequences:  A308427 A308428 A308429 * A308431 A308432 A308433

KEYWORD

sign,base,look

AUTHOR

Andrea Fornaciari, May 26 2019

STATUS

approved

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

License Agreements, Terms of Use, Privacy Policy. .

Last modified August 18 15:00 EDT 2019. Contains 326106 sequences. (Running on oeis4.)