I'm trying to make a script to find factors of numbers... The numbers that evenly divide into a given number. I've got part of a script, an example of which can be seen here:
http://www.uni.uiuc.edu/~mberman1/ethan/factor/?mode=doFactor&number=9
(it'll use the number 9).
My code is below, and my problem is this. When you view the example, it'll display all of the possible divisions - both the integers and the decimal numbers. I only want the integer numbers (1,2,3, etc.) displayed. I do NOT want the decimal numbers (1.12321412424, 1123.124214124124, etc.) displayed.
Is there some function to do this, or can anyone think of a way to only display the integer numbers?
TIA
<?PHP
$mode = $_GET['mode'];
if($mode == "") {
include("form.htm");
} elseif ($mode = "doFactor") {
$number = $_GET['number'];
for ($i = 1; $i <= $number; $i++) {
$tnum = $number/$i;
echo $i . ":" . $tnum;
echo "<br>";
}
}
?>