check-if-number-is-a-sum-of-powers-of-three
1.0.0
Check if Number is a Sum of Powers of Three
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#include <bits/stdc++.h>
2
3
using namespace
std;
4
5
class
Solution
6
{
7
public
:
8
bool
checkPowersOfThree
(
int
n)
9
{
10
while
(n > 0)
11
{
12
int
remainder = n % 3;
13
if
(remainder == 2)
14
return
false
;
15
n /= 3;
16
}
17
return
true
;
18
}
19
};
20
21
int
main
()
22
{
23
cout <<
"output: "
<<
Solution
().
checkPowersOfThree
(12) <<
'\n'
;
24
return
0;
25
}
Solution
Definition
main.cpp:6
Solution::checkPowersOfThree
bool checkPowersOfThree(int n)
Definition
main.cpp:8
main
int main()
Definition
main.cpp:21
main.cpp
Generated by
1.9.8