A function with a range set, that contains differences of two prime numbers.

32 Views Asked by At

I've been asked to give a total and computable function $f:\mathbb{N} \rightarrow \mathbb{N}$, with a range set $R_f = B$ with $B$ defined as follows: $$B = \{n \mid \text{there exist two primes }p,q \geq 2 \text{ with } n = p-q\}$$


I don't know how to approach the problem. I've been reading about prime gabs of two consecutive primes and there properties but i did't get any idea. $p,q$ don't have to be consecutive but i think n must be a sum of consecutive prime gabs. (e.g. if there is a prime number $s$ between $p$ and $q$, then $n$ will be the sum of differences $n = (s-q) + (p - s)$).

Please help!

1

There are 1 best solutions below

1
On

Given $n$, let $a=\lfloor\sqrt n\rfloor$ and $b=\min\{n-a^2,a\}$. Then $a$ runs through all of $\Bbb N$, and $b$ takes all values in the interval $0\le b\le a$. Let $p$ be the $(b+1)$st prime and $q$ the $(a+2)$nd prime. Finally, let $f(n)=q-p$.