function to detect prime number here we have used sieve method https : www . geeksforgeeks . org / sieve - of - eratosthenes / to detect prime number
< ? php function sieve ( $ n , & $ prime ) { for ( $ p = 2 ; $ p * $ p <= $ n ; $ p ++ ) {