-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathPowerOfThreeSln.cs
More file actions
29 lines (28 loc) · 822 Bytes
/
PowerOfThreeSln.cs
File metadata and controls
29 lines (28 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ==============================================================================
* 功能描述:UglyNumberSln
* 创 建 者:gz
* 创建日期:2017/5/26 12:23:33
* ==============================================================================*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Given an integer, write a function to determine if it is a power of three.
// Follow up:
// Could you do it without using any loop / recursion?
namespace Math.Lib
{
/// <summary>
/// PowerOfThreeSln
/// </summary>
public class PowerOfThreeSln
{
public boolean isPowerOfThree(int n)
{
int powcnt = 0;
if(Math.Pow(3,19)<Int32.MaxValue && Math.Pow(3,20)>Int32.MaxValue)
powcnt = 19;
return ( n>0 && Math.Pow(3,19)%n==0);
}
}
}