View Single Post
Old 2005-12-29, 21:59   #3
grandpascorpion
 
grandpascorpion's Avatar
 
Jan 2005
Transdniestr

503 Posts
Default

I don't think you need to sieve even.

Define P as the lowest number that contains all the factors under some number N
Define X as the first number greater than your input number M that also contains all the factors under N.

then X= (1+int(M/P))*P

("int" rounds down)

Finding the closest to M (either below or above) would just require a couple more simple steps.

It doesn't really matter what the factors of P are either. (i.e. prime factors from 2 to N, all integers from 2 to N). The same idea would hold.

Last fiddled with by grandpascorpion on 2005-12-29 at 22:03
grandpascorpion is offline   Reply With Quote