Skip to content

Instantly share code, notes, and snippets.

@rakeybulhasan
Created May 15, 2013 08:29
Show Gist options
  • Save rakeybulhasan/5582449 to your computer and use it in GitHub Desktop.
Save rakeybulhasan/5582449 to your computer and use it in GitHub Desktop.
<?php
function primefactor($num) {
$sqrt = sqrt($num);
for ($i = 2; $i <= $sqrt; $i++) {
if ($num % $i == 0) {
return array_merge(primefactor($num/$i), array($i));
}
}
return array($num);
}
$y=1;
while($y<=500){
$res= primefactor($y);
$default_array= array(2,3,5,7);
$arr_unique= array_unique($res);
$result = array_intersect($default_array, $arr_unique);
$diff= array_diff($arr_unique,$result);
if(empty($diff)){
echo $y;
echo '<br>';
}
$y++;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment