This site is supported by donations to The OEIS Foundation.

# Characteristic function of prime numbers

(Redirected from Characteristic function of the primes)

The characteristic function of prime numbers, which gives 1 if the number is a prime number and 0 otherwise, is defined as

${\displaystyle \chi _{\rm {prime}}(n)\equiv \pi (n)-\pi (n-1)\,}$

where ${\displaystyle \scriptstyle \pi (n)\,}$ is the prime counting function.

It is also given by

${\displaystyle \chi _{\rm {prime}}(n)=[\gcd(n,\lfloor {\sqrt {n}}\rfloor \#)=1],\,}$

where ${\displaystyle \scriptstyle \gcd(m,\,n)\,}$ is the greatest common divisor of ${\displaystyle \scriptstyle m\,}$ and ${\displaystyle \scriptstyle n\,}$, ${\displaystyle \scriptstyle n\#\,}$ is the primorial of ${\displaystyle \scriptstyle n\,}$ and ${\displaystyle \scriptstyle [\cdot ]\,}$ is the Iverson bracket.

For example, ${\displaystyle \scriptstyle \chi _{\rm {prime}}(7)\,=\,1\,}$, ${\displaystyle \scriptstyle \chi _{\rm {prime}}(8)\,=\,0\,}$. (See A010051 for a listing going up to 100000.)

 1     ${\displaystyle \scriptstyle \chi _{\rm {prime}}(n)\,}$
0

## Asymptotic probability

The characteristic function of prime numbers is equal to 1 with the slowly decreasing (converging towards 0) asymptotic probability

${\displaystyle \lim _{n\to \infty }P(\chi _{\rm {prime}}(n)=1)={\frac {1}{\log(n)}}={\frac {\log(e)}{\log(n)}},\,}$

and equal to 0 with the slowly increasing (converging towards 1) asymptotic probability

${\displaystyle \lim _{n\to \infty }P(\chi _{\rm {prime}}(n)=0)=1-{\frac {1}{\log(n)}}={\frac {\log(n)-1}{\log(n)}}={\frac {\log(n/e)}{\log(n)}}.\,}$

Observe that if you set ${\displaystyle \scriptstyle n\,}$ to ${\displaystyle \scriptstyle e\,}$ = 2.718281828459..., giving a probability of ${\displaystyle \scriptstyle n\,}$ being prime equal to 1, we have that both integers surrounding ${\displaystyle \scriptstyle e\,}$, i.e. 2 and 3, are prime!

The above limits imply that 0% of the integers are prime (100% of the integers are composite), yet the infinite series

${\displaystyle \sum _{n=1}^{\infty }{\frac {1}{p_{n}}}=\sum _{n=1}^{\infty }[\chi _{\rm {prime}}(n)=1]\,{\frac {1}{n}}=\sum _{n=1}^{\infty }[\gcd(n,\lfloor {\sqrt {n}}\rfloor \#)=1]\,{\frac {1}{n}}\to \infty ,\,}$

where ${\displaystyle \scriptstyle p_{n}\,}$ is the ${\displaystyle \scriptstyle n\,}$th prime, happens to diverge towards infinity!