View Single Post
Old 08-30-2009, 08:31 PM   PM User | #1
funnymoney
Regular Coder

 
funnymoney's Avatar
 
Join Date: Aug 2007
Posts: 364
Thanks: 17
Thanked 24 Times in 24 Posts
funnymoney is an unknown quantity at this point
Square root script

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 Code:
<?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 Idea Factory
funnymoney is offline   Reply With Quote