Here's mine, did someone say GOLF!
cheers
tachyon
print sqroot(2,100); # long version sub sqroot { $number = shift; $iterate = shift; $guess = $number; for (0..$iterate) { $guess = (($number/$guess) + $guess)/2 ; } return $guess; } # golf at 44 strokes sub sqroot { ($n,$i)=@_;$g=$n;$g=($n/$g+$g)/2for 0..$i;$g }
In reply to Re: Square Root algorithm
by tachyon
in thread Square Root algorithm
by nysus
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |