Advertisement
StoneHaos

13

Nov 28th, 2021
925
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. string tothird(int n) {
  7.     if (n < 3)
  8.         return to_string(n);
  9.     return tothird(n / 3) + to_string(n % 3);
  10. }
  11.  
  12. int main() {
  13.     int n;
  14.     cin >> n;
  15.     cout << n << "(10) = " << tothird(n) << "(3)\n";
  16.     return 0;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement