# Frequency of twin primes

Is there a function that gives the frequency with which twin primes less than a particular number, N (assuming N is not a part of a twin prime) occur? I've tried with a program but I did not notice any pattern........

:

   int pc(long double n)   \\pc:prime check
{
long double i=2, f=0;
for(;i<=n/2;i++)
{
if(fmod(n,i)==0){f=1;break;}
else;
}
if(f)return 0;
else return 1;
}

int sc(int n)   \\sc:square check
{
if(fmod(sqrt(n),1)==0)return 1;
else return 0;
}

void main()
{
long double i=1,n=1000;
cout<<"n\t\t6n-1\t\t6n+1\t\tRem.";
for(;i<=n;i++)
{
cout<<"\n"<<i<<"\t\t"<<6*i-1<<"\t\t"<<6*i+1;
if(pc(6*i-1)&&pc(6*i+1))cout<<"\t    TWINTWINTWIN";
else
{
if(sc(6*i-1)||sc(6*i+1))
{
if(sc(6*i-1))cout<<"\t(-)???SQUARESQUARE???";
else  cout<<"\t(+)???SQUARESQUARE???";
}
else cout<<"\t     ---ONE---";
}
}

}


:

-
As it is still open whether there are infinitely many twin primes, it does not really make sense to speak of a frequency. –  Tobias Kildetoft Aug 9 '12 at 13:40
Suppose t and t+2 are primes. Can we tell when will the next twin prime occur? This is what I meant. –  Swapnanil Saha Aug 9 '12 at 13:42
We can not even be sure that a next twin prime will occur at all. –  Tobias Kildetoft Aug 9 '12 at 13:43
@SwapnanilSaha: the problem is that if there are only finitely many twin primes, there is a value of t for which the answer is "never". We can only answer your question as stated if we know if there are infinitely many twin primes. Perhaps you want to know if there are any known results up to some particular finite constant N (e.g. twin primes up to 1E20)? –  Niel de Beaudrap Aug 9 '12 at 13:44
@SwapnanilSaha: Perhaps you should revise your question so that everyone knows that this is what you have in mind, and not something which requires a solution to the twin primes problem. ;-) –  Niel de Beaudrap Aug 9 '12 at 13:48

If $\pi_2(x)$ is the number of primes $p\le x$ with $p+2$ prime then it is conjectured that : $$\pi_2(x)\sim 2C_2 \frac x{(\log x)^2}$$ with $C_2\approx 0.660161815$ the Twin prime constant
This $\pi_2(x)$ function is less well known than $\pi(x)$ of course...