Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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


Comment on Re: Re: computing square root by hand -- no sqrt (golf, beginner)
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://165486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (16)
As of 2014-09-02 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (24 votes), past polls