Advertisement
Guest User

some kind of recursive function

a guest
Sep 2nd, 2015
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pow(num: int, exp: int): int {
  2.     return pow_r(num, num, exp);
  3. }
  4.  
  5. function pow_r(num: int, base: int, exp: int): int {
  6.     if (exp == 0) return 1;
  7.     else if (exp == 1) return num;
  8.     return pow_r(num * base, base, --exp);
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement