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
3using namespace std;
4
6{
7public:
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
21int main()
22{
23 cout << "output: " << Solution().checkPowersOfThree(12) <<'\n';
24 return 0;
25}
bool checkPowersOfThree(int n)
Definition main.cpp:8
int main()
Definition main.cpp:21