Ugly Number III


  • 0

    When give a positive number N, we can get the corresponding maximum ugly number M that no greater than N, please write a program to calculate the sequence number of M in all the ugly numbers.

    Ugly numbers are positive numbers whose prime factors only include 2, 3 and 5. For example:

    give 1 -> return 1
    give 2 -> return 2
    give 3 -> return 3
    give 4 -> return 4
    give 5 -> return 5
    give 6-> return 6
    give 7 -> return 6
    give 8 -> return 7
    give 9 -> return 8
    give 10 -> return 9
    give 11 -> return 9
    give 12 -> return 10
    ...
    

    Note that 1 is typically treated as the first ugly number.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.