Google
 

Friday, December 21, 2007

Easier Way to Find Perfect Squares

A much easier way to find perfect squares:
This method uses integer roots to find perfect squares instead of integer squares to find integer roots.

<?

# initial value
$i = 0;

#set any limit you want
$setSomeLimit = 10000;

# do it! .... do it! ... do it!
for ($n = 1; $n < sqrt($setSomeLimit; $n++)
{
// Find the square
$s= $n * $n;

print "
perfect_square_root is of $s is $n";
}

?>