in reply to Re^7: OT: Finding Factor Closest To Square Root
in thread OT: Finding Factor Closest To Square Root
If N = (p1^a1)*(p2^a2)*...(pR^aR) then sigma(N,0) = (a1+1)*(a2+1)*...(aR + 1)
This number is usually very small, even for huge N.
If sigma($N,0) is reasonable, you can call divisors($N), which returns a list of all the divisors in order. A simple binary search will find the desired number.
This should be incredibly faster than brute-force countdown searches for large N.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^9: OT: Finding Factor Closest To Square Root
by BrowserUk (Patriarch) on Feb 22, 2005 at 19:14 UTC | |
by tall_man (Parson) on Feb 22, 2005 at 20:44 UTC |