码迷,mamicode.com
首页 > 其他好文 > 详细

263. 丑数

时间:2020-04-14 20:53:04      阅读:38      评论:0      收藏:0      [点我收藏+]

标签:丑数   color   solution   code   while   false   bool   pre   public   

 1 class Solution 
 2 {
 3 public:
 4     bool isUgly(int num) 
 5     {
 6         if (num == 0) return false;
 7         while (num % 2 == 0) num /= 2;
 8         while (num % 3 == 0) num /= 3;
 9         while (num % 5 == 0) num /= 5;
10         return num == 1;
11     }
12 };

 

263. 丑数

标签:丑数   color   solution   code   while   false   bool   pre   public   

原文地址:https://www.cnblogs.com/yuhong1103/p/12700265.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!