We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
编写一个程序判断给定的数是否为丑数。
丑数就是只包含质因数 2, 3, 5 的正整数。
示例 1:
输入: 6 输出: true 解释: 6 = 2 × 3
示例 2:
输入: 8 输出: true 解释: 8 = 2 × 2 × 2
示例 3:
输入: 14 输出: false 解释: 14 不是丑数,因为它包含了另外一个质因数 7。
function isUgly(num) { if (num <= 0) { return false; } if (num == 1) { return true; } if (num % 2 == 0) { return isUgly(num / 2); } if (num % 3 == 0) { return isUgly(num / 3); } if (num % 5 == 0) { return isUgly(num / 5); } return false; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
编写一个程序判断给定的数是否为丑数。
丑数就是只包含质因数 2, 3, 5 的正整数。
示例 1:
示例 2:
示例 3:
解答
The text was updated successfully, but these errors were encountered: