Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Here's an informal proof of our conjecture "The factor of N closest to sqrt(N) is less than sqrt(N)".
  1. Let M be the positive square root of N. (M*M = N, M>0)
  2. 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))
  3. 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)
  4. 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)
  5. So, (M-X) * (M+Y) = N
  6. Multiplying out, M^2 + M*(Y-X) - X*Y = N
  7. But M^2 = N (by definition)
  8. Substituting: N + M*(Y-X) - X*Y = N
  9. Subtracting N: M*(Y-X) - X*Y = 0
  10. Since X and Y are positive (by definition, step 4), the term -X*Y is negative
  11. If -X*Y is negative, the only way for the entire sum to equal 0 is if the term M*(Y-X) is positive
  12. But M is positive (step 1), so (Y-X) must also be positive, which means that Y is greater than X.
  13. 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.

In reply to Re^4: Closest factor less than sqrt(N) [proof] by sleepingsquirrel
in thread OT: Finding Factor Closest To Square Root by QM

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (5)
    As of 2020-07-02 05:12 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found