funnymoney
08-30-2009, 08:31 PM
If you ever wandered how square root program might look light, like i did, well, this is how i figure it out to be. Someone could look how to make it work with float numbers. ;)
<?php
function square_root($square) {
while ($i < $square) {
if ($i*$i == $square) {
$square_root = $i;
}
$i++;
}
if (!$square_root) {
$square_root = "Square root is not int";
}
return $square_root;
}
print square_root(49);
?>
<?php
function square_root($square) {
while ($i < $square) {
if ($i*$i == $square) {
$square_root = $i;
}
$i++;
}
if (!$square_root) {
$square_root = "Square root is not int";
}
return $square_root;
}
print square_root(49);
?>