From 78726f21c0787e866b1218d5089d974c266815fe Mon Sep 17 00:00:00 2001 From: chayan das <110921638+Chayandas07@users.noreply.github.com> Date: Tue, 4 Mar 2025 12:17:23 +0530 Subject: [PATCH] Create 1780. Check if Number is a Sum of Powers of Three --- 1780. Check if Number is a Sum of Powers of Three | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 1780. Check if Number is a Sum of Powers of Three diff --git a/1780. Check if Number is a Sum of Powers of Three b/1780. Check if Number is a Sum of Powers of Three new file mode 100644 index 0000000..ac740cb --- /dev/null +++ b/1780. Check if Number is a Sum of Powers of Three @@ -0,0 +1,13 @@ +class Solution { +public: + bool checkPowersOfThree(int n) { + while(n > 0){ + int remainder = n % 3; + if(remainder == 2){ + return false; + } + n = n / 3; + } + return true; + } +};