Python simple solution

  • -3

    just writing my python solution, I know this will not be the best answer, but i think this one is easy to read.

        for p in 2,3,5:
            while num%p == 0 and num >0:
                num /= p 
        return num == 1:

  • 0
    if someBooleanExpression:
        return True
        return False

    is ridiculous in general, but if it's like half of your whole code... come on... just do

    return num == 1

  • 0

    sorry, I m a beginner. I have though about this question before, but I am still confused.
    if I just return num ==1, so how about the False condition?

  • 0

    What about it? If num == 1 is True, then return num == 1 returns True, and if it is False, then that returns False.

Log in to reply

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