Python simple solution


  • -3
    J

    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
    M
    if someBooleanExpression:
        return True
    else:
        return False
    

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

    return num == 1

  • 0
    J

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


  • 0
    M

    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.