Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: OT: Finding Factor Closest To Square Root

by chas (Priest)
on Feb 20, 2005 at 22:48 UTC ( [id://432908]=note: print w/replies, xml ) Need Help??


in reply to Re^2: OT: Finding Factor Closest To Square Root
in thread OT: Finding Factor Closest To Square Root

Programming F(n) for benchmarking purposes is interesting. However, the fastest way of all is probably:
F(n)= integer nearest (1/sqrt 5)[(1+sqrt 5)/2]^n

This isn't perl, but it would only take a line. (If n is extremely large, the exponentiation might become inaccurate, though...)
chas

Replies are listed 'Best First'.
Re^4: OT: Finding Factor Closest To Square Root
by QM (Parson) on Feb 21, 2005 at 01:26 UTC
    Programming F(n) for benchmarking purposes is interesting. However, the fastest way of all is probably:
    F(n)= integer nearest (1/sqrt 5)[(1+sqrt 5)/2]^n
    Yes, but I'd like to understand for myself why various approaches are slower. Which means I have to find a number of independent approaches.
    If n is extremely large, the exponentiation might become inaccurate, though.
    That's why you use arbitrary precision, like one of the Math::Big* modules.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2024-04-26 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found