im looking for a more efficient algorithm,

is there any known one? ive checked my math books and c++ book

and really didnt find anything more efficient than the following :

```
int first_prime(int num)
{
for (int i=2;i<sqrt(num);i++)
{
if (num%i==0)
{
if (isprime(i));
return(i);
}
}
}
bool isprime(int prime)
{
for (int i=2;i<sqrt(prime);i++)
{
if (prime%i==0)
return(false);
}
return(true);
}
```

thank, good day!