I'm coding a encryption program where I need to generate random prime.

I wrote this code

```
for(i=3; i<10000000; i=i+2 )
{
for(j=2; j <= sqrt(i); j++ )
{
if(!(i%j)) break;
}
if (j>sqrt(i))
{
cout<<i << " ";
}
}
```

This tests a number till is square root. Its good for small prime numbers. But encryption needs prime of range 100 digit. But a 20 digit prime would be fine. How to do this ? I googled and found AKS algorithm, but I'm finding it difficult to code. So can anyone suggest some other algorithm ? And how to get a 20 digit prime.