File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed 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
+ // Given an integer, write a function to determine if it is a power of three.
11
+ // Follow up:
12
+ // Could you do it without using any loop / recursion?
13
+ namespace Math . Lib
14
+ {
15
+ /// <summary>
16
+ /// PowerOfThreeSln
17
+ /// </summary>
18
+ public class PowerOfThreeSln
19
+ {
20
+ public boolean isPowerOfThree ( int n )
21
+ {
22
+ int powcnt = 0 ;
23
+ if ( Math . Pow ( 3 , 19 ) < Int32 . MaxValue && Math . Pow ( 3 , 20 ) > Int32 . MaxValue )
24
+ powcnt = 19 ;
25
+ return ( n > 0 && Math . Pow ( 3 , 19 ) % n == 0 ) ;
26
+ }
27
+
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments