// Number to factor
$num = 60;
// Loop from the number to factor down to 1
for($i=$num; $i>=1; $i--){
// If it divides evenly
if($num % $i === 0 ){
// Output result of division, which is a factor
echo $num / $i . '<br />';
}
}
Output:
1 2 3 4 5 6 10 12 15 20 30 60
*To find a factor, divide by a number, and if the result is a whole number, then both the answer, and the number you divided by are factors.*
Factor Finder