Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • Starting from number - 1 and working down is functionally correct yet inefficient. A possible factor is much more likely a small value than a large one. All factor tests above the square root of number and less than number fail: (number % i) == 0 is never true there. With large number, this is expensive to test with no benefit. Commented Apr 19, 2022 at 9:29
  • This appears to be a reply to another answer, rather than answer of it own. Please only use answers to post content that directly addresses the question. You can use comments to reply to existing answers. Commented Jul 11 at 16:04