leetcode263

原创 2016年06月02日 11:21:10

263 easy ugly number
*Write a program to check whether a given number is an ugly number.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.
Note that 1 is typically treated as an ugly number.*

class Solution(object):
    def isUgly(self, num):
        """
        :type num: int
        :rtype: bool
        """
        if num<=0:
            return False
        for i in [2,3,5]:
            while num%i==0:
                num/=i
        return num==1
版权声明:本文为博主原创文章,未经博主允许不得转载。 举报

相关文章推荐

LeetCode 263 Ugly Number(丑数)

翻译写一个程序来检查给定的数字是否是丑数(Ugly number)。丑数是一个正数,它的质因子只包括2、3、5。例如,6、8是丑数,而因为包含了7这个因子,所以14不是丑数。请注意,1通常被视为一个丑...
  • NoMasp
  • NoMasp
  • 2016-01-18 13:24
  • 1754

剑指offer 面试题34:寻找丑数(Leetcode 263.ugly number)解题报告

剑指offer 面试题34:寻找丑数 题目:把只包含因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含因子7。习惯上我们把1当做是第一个丑数。请按从小到大...

我是如何成为一名python大咖的?

人生苦短,都说必须python,那么我分享下我是如何从小白成为Python资深开发者的吧。2014年我大学刚毕业..

leetcode263_264:Ugly Number & Ugly Number II

Ugly NumberWrite a program to check whether a given number is an ugly number.Ugly numbers are positi...

Leetcode 263. Ugly Number & 264. Ugly Number II

263. Ugly Number Total Accepted: 58196 Total Submissions: 157221 Difficulty: Easy Write a pro...

[leetcode]263. Ugly Number

题目 Write a program to check whether a given number is an ugly number. Ugly numbers are posit...

Leetcode 263-264 ugly number

Write a program to check whether a given number is an ugly number.Ugly numbers are positive numbers ...

20170307-leetcode-263-Ugly Number

1.DescriptionWrite a program to check whether a given number is an ugly number.Ugly numbers are posi...

LeetCode 202. Happy Number & 263. Ugly Number

202. Happy Number Write an algorithm to determine if a number is "happy". A happy number is ...

codeforces Round #263(div2) E解题报告

E. Appleman and a Sheet of Paper time limit per test 2 seconds memory limit per test 256...

Sorenson H.263 Stream Format

Sorenson H.263 VideoFormat: ( which be used in FLV File ) 1.instruction: Removed Part from Standard...
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)