more useful options  
PerlMonks 
Re^4: OT: Finding Factor Closest To Square Rootby kvale (Monsignor) 
on Feb 20, 2005 at 07:02 UTC ( #432844=note: print w/ replies, xml )  Need Help?? 
I think the method I sketched does not do what you think :) Lets take your example. The square root is 234.277. The largest prime factor is 19. The largest remaining factor is 19, but 19*19 > 234.77, so we try the next largest factor, which is 2. 19*2 <= 234.77, so we keep it. The next largest is 2, and 19*2*2 <= 234.77, so we keep it. The next largest (and final) factor is 2, and 19*2*2*2 = 152 < 234.77, so we stop there. 152 is our best attempt for factor closest to but <= sqrt(54872). A little thought shows that the greedy method from above will give 54872/152 = 361. If one uses a linear distance, then 152 is the closest factor by the grredy heuristic. Mark
In Section
Seekers of Perl Wisdom

