Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: computing square root by hand -- no sqrt (golf, beginner)

by jynx (Priest)
on May 09, 2002 at 20:03 UTC ( #165486=note: print w/replies, xml ) Need Help??


in reply to Re: computing square root by hand -- no sqrt (golf, beginner)
in thread computing square root by hand -- no sqrt (golf, beginner)


a reinterpretation of japhy's solution gives 54:
$_=pop;$l^$_?$l=$_:die"$_\n"while$_=($_+$ARGV[0]/$_)/2
jynx

update: this works at 53:

$_=pop;$l^$_?$l=$_:die"$_\n"while($_+=$ARGV[0]/$_)/=2
update2: using the comma instead of quotes for die it's 52:
$_=pop;$l^$_?$l=$_:die$_,$/while($_+=$ARGV[0]/$_)/=2

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://165486]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2016-12-11 15:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (169 votes). Check out past polls.