eg0rmaffin

r_power

Jul 6th, 2019
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.38 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int
  4. ft_r_power (int nb, int power)
  5. {
  6.  
  7.  
  8.   if (power == 0)
  9.     {
  10.       return (1);
  11.     }
  12.   else if (power < 0)
  13.     {
  14.       return (0);
  15.     }
  16.  
  17.  
  18.                 nb = nb * ft_r_power(nb, power - 1);
  19.                
  20.    
  21.   return (nb);
  22. }
  23.  
  24.  
  25.  
  26.  
  27.  
  28. int
  29. main ()
  30. {
  31.   int a = 16;
  32.   int b = 5;
  33.   ft_r_power (a, b);
  34.   printf ("%d", ft_r_power (a, b));
  35. }
Advertisement
Add Comment
Please, Sign In to add comment