- class Solution {
- public:
- bool b = false;
- bool isUgly(int num) {
- if( num <= 0 )
- return b;
- if( 1 == num )
- return 1;
- for( int i = 1; i < 10; ++i )
- {
- if ( ( i == 2 || i == 5 || i == 3) && 0 == num % i )
- {
- num = num / i;
- b = isUgly( num );
- }
- }
- return b;
- }
- };
- //该片段来自于http://www.codesnippet.cn/detail/0709201513613.html
来源: http://www.codesnippet.cn/detail/0709201513613.html