Leetcode 504 Base 7 Solution in c++ | Hindi Coding Community

0

 


Given an integer num, return a string of its base 7 representation.


Example 1:


Input: num = 100

Output: "202"




string convertToBase7(int num) {
int res = 0;
for(int i=0; num!=0; res += pow(10,i++)*(num % 7), num /= 7) {}
return to_string(res);
}

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !