Advertisement
Guest User

Potência Recursivamente

a guest
Dec 15th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.23 KB | None | 0 0
  1.  
  2.  
  3.  
  4. long int func(long int x, int n)
  5. {
  6.   if (n > 1)
  7.   {
  8.     return x * func(x, --n);
  9.   }
  10.  
  11.   return x;
  12. }
  13.  
  14.  
  15. int main ()
  16. {
  17.   long int x, result;
  18.   int n;
  19.  
  20.   x = 2;
  21.   n = 10;
  22.  
  23.   result = func(2, 10);
  24.  
  25.   return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement