Advertisement
pochti_da

Untitled

May 24th, 2021
849
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.27 KB | None | 0 0
  1. #include <string>
  2.  
  3. std::string gen_power(uint32_t n) {
  4.     if (n == 0) {
  5.         return "1";
  6.     } else if (n == 1) {
  7.         return "x";
  8.     }
  9.  
  10.     if (n & 1) {
  11.         return gen_power(n - 1) + "x*";
  12.     } else {
  13.         return gen_power(n / 2) + "!*";
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement