Find the smallest regular number that is not less than N

后端 未结 8 2116
清歌不尽
清歌不尽 2020-12-16 19:08

Regular numbers are numbers that evenly divide powers of 60. As an example, 602 = 3600 = 48 × 75, so both 48 and 75 are divisors of a power of 60.

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 19:20

    You want to find the smallest number m that is m >= N and m = 2^i * 3^j * 5^k where all i,j,k >= 0.

    Taking logarithms the equations can be rewritten as:

     log m >= log N
     log m = i*log2 + j*log3 + k*log5
    

    You can calculate log2, log3, log5 and logN to (enough high, depending on the size of N) accuracy. Then this problem looks like a Integer Linear programming problem and you could try to solve it using one of the known algorithms for this NP-hard problem.

提交回复
热议问题