Here's an informal proof of our conjecture "The factor of N closest to sqrt(N) is less than sqrt(N)".
- Let M be the positive square root of N. (M*M = N, M>0)
- The closest factor to M is bewteen 1 and 2*M. (i.e. 1 is closer to M than any number greater than twice M. (M-1 < 2*M-M))
- For every pair of numbers whose product is N, one of the pair will be greater than M and the other less than M. (the product of two numbers greater than M is greater than N, and the product of two numbers less than M would be less than N)
- Take a pair of numbers whose product is N. Call the smaller (M-X) and the larger (M+Y). (i.e. X>0, Y>0)
- So, (M-X) * (M+Y) = N
- Multiplying out, M^2 + M*(Y-X) - X*Y = N
- But M^2 = N (by definition)
- Substituting: N + M*(Y-X) - X*Y = N
- Subtracting N: M*(Y-X) - X*Y = 0
- Since X and Y are positive (by definition, step 4), the term -X*Y is negative
- If -X*Y is negative, the only way for the entire sum to equal 0 is if the term M*(Y-X) is positive
- But M is positive (step 1), so (Y-X) must also be positive, which means that Y is greater than X.
- Finally, if Y is greater than X, the smaller factor, (M-X) is closer to M than (M+Y), so you can limit your factor search to numbers less than sqrt(N).
-- All code is 100% tested and functional unless otherwise noted.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|