File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 53
53
<Compile Include =" Properties\AssemblyInfo.cs" />
54
54
<Compile Include =" ReverseIntegarSln.cs" />
55
55
<Compile Include =" Sqrtx.cs" />
56
+ <Compile Include =" UglyNumberSln.cs" />
56
57
</ItemGroup >
57
58
<ItemGroup >
58
59
<Content Include =" Floyd%27sTortoiseandHare.jpg" />
Original file line number Diff line number Diff line change
1
+ /* ==============================================================================
2
+ * 功能描述:UglyNumberSln
3
+ * 创 建 者:gz
4
+ * 创建日期:2017/5/26 12:23:33
5
+ * ==============================================================================*/
6
+ using System ;
7
+ using System . Collections . Generic ;
8
+ using System . Linq ;
9
+ using System . Text ;
10
+
11
+ namespace Math . Lib
12
+ {
13
+ /// <summary>
14
+ /// UglyNumberSln
15
+ /// </summary>
16
+ public class UglyNumberSln
17
+ {
18
+ public bool IsUgly ( int num )
19
+ {
20
+ if ( num <= 0 ) return false ;
21
+ if ( num == 1 ) return true ;
22
+ while ( num > 1 )
23
+ {
24
+ if ( num % 2 == 0 )
25
+ num /= 2 ;
26
+ else if ( num % 3 == 0 )
27
+ num /= 3 ;
28
+ else if ( num % 5 == 0 )
29
+ num /= 5 ;
30
+ else return false ;
31
+ }
32
+ return true ;
33
+ }
34
+
35
+ }
36
+ }
You can’t perform that action at this time.
0 commit comments