Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 8061f88

Browse files
ADD Ugly-Number problem #75
1 parent d6a318f commit 8061f88

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

‎Easy/ugly-number.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
public class Solution
2+
{
3+
public static bool IsUgly(int n)
4+
{
5+
if (n <= 0)
6+
{
7+
return false;
8+
}
9+
10+
foreach (byte num in new byte[] { 2, 3, 5 })
11+
{
12+
while (n % num == 0)
13+
{
14+
n /= num;
15+
}
16+
}
17+
18+
return (n == 1);
19+
}
20+
21+
static void Main()
22+
{
23+
Console.WriteLine(IsUgly(7));
24+
}
25+
}
26+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /