[SOLVED] Proably just a rushed mistake...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
TS_Death_Angel
Forum Commoner
Posts: 31
Joined: Sat Dec 31, 2005 8:49 am

[SOLVED] Proably just a rushed mistake...

Post 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...
TS_Death_Angel
Forum Commoner
Posts: 31
Joined: Sat Dec 31, 2005 8:49 am

Post by TS_Death_Angel »

Nevermind, just close this, I made it completely wrong XD
Post Reply