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 50f2237

Browse files
committed
1780
1 parent 9f18ab8 commit 50f2237

File tree

1 file changed

+19
-0
lines changed
  • Medium/1780. Check if Number is a Sum of Powers of Three

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
class Solution
3+
{
4+
/**
5+
* @param Integer $n
6+
* @return Boolean
7+
*/
8+
public function checkPowersOfThree($n)
9+
{
10+
while ($n > 0) {
11+
12+
if ($n % 3 == 2) {
13+
return false;
14+
}
15+
$n = intdiv($n, 3);
16+
}
17+
return true;
18+
}
19+
}

0 commit comments

Comments
(0)

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