Bipartite primes

Let p ( n ) p(n) denote binary representation of natural number n n .For example, p ( 7 ) = 111 p(7)=111 .

Let A ( n ) = ( p ( n + p ( n ) ) n ) A(n) = (p(n+p(n))-n) for natural number n n .

For how many integers between 3 , 10000 {3,10000} (both inclusive) is A ( n ) A(n) a positive prime number.


The answer is 120.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Bill Bell
Mar 1, 2016
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from sympy import isprime

def p(n):
    return int(bin(n)[2:])

def A(n):
    return p(n+p(n))-n

count=0
for n in range(3,10001):
    compare=A(n)
    count+=compare>0 and isprime(compare)

print (count)

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...