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 5ffd11a

Browse files
power of three
1 parent f2eb896 commit 5ffd11a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

‎Math/Math.Lib/PowerOfThreeSln.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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+
}

0 commit comments

Comments
(0)

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