Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

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

by jynx (Priest)
on May 09, 2002 at 20:03 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://165486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-29 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found