diff --git a/Program's_Contributed_By_Contributors/C++/PowerOfFour.cpp b/Program's_Contributed_By_Contributors/C++/PowerOfFour.cpp new file mode 100644 index 0000000000..b5b659887e --- /dev/null +++ b/Program's_Contributed_By_Contributors/C++/PowerOfFour.cpp @@ -0,0 +1,30 @@ +class Solution { +public: + double value4(double d) +{ + return (log2(d))/2; +} +bool is_integer(float k) +{ + return std::floor(k) == k; +} + bool isPowerOfFour(int n) { + if(n<=0){ + return false; + } + if(n==1){ + return true; + } + if(n%4!=0){ + return false; + } + else{ + if(is_integer(value4(n))){ + return true; + } + else{ + return false; + } + } + } +}; \ No newline at end of file