Page 1 of 1

[SOLVED] Proably just a rushed mistake...

Posted: Thu Jan 05, 2006 3:51 pm
by TS_Death_Angel
I was writing this short peice of code for a friend, but I just can't get it to work! By the way, this code is supposed to return factor trees (not formatted) of numbers.

Code: Select all

<?php

function is_prime ($inputnum)
{
$i = 1;
while($i<=$inputnum)
{
if(!is_float($inputnum/$i))
{
$factors .= $inputnum/$i.',';
$i++;
} else {
$i++;
}
}
$result = explode(',',$factors);
$count  = count($result);
if($count>2)
{
return FALSE;
} else {
return TRUE;
}
}


$number = 10;

$i      = 1;

while($i<=$number)
{
$var = $number/$i;
if(is_prime($var) && !is_float($var))
{
$primes .= $var;
$i++;
} else {
$i++;
}
}
echo $primes;


?>
As you can see, it's pretty simple. But I know I've done something wrong...

Posted: Thu Jan 05, 2006 4:18 pm
by TS_Death_Angel
Nevermind, just close this, I made it completely wrong XD