Traversing all numbers to find first pair
for ( $ i = 2 ; $ i < $ n ; $ i ++ ) { $ x = ( int ) ( $ n / $ i ) ; if ( $ isPrime [ $ i ] && $ isPrime [ $ x ] and $ x != $ i and $ x * $ i == $ n ) { echo $ i . " ▁ " . $ x ; $ flag = 1 ; return ; } } if ( ! $ flag ) echo " No ▁ such ▁ pair ▁ found " ; }