Advertisement
fueanta

Recursive Power Method

Jun 3rd, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.22 KB | None | 0 0
  1.     public static int power(int m, int n)
  2.     {
  3.         if (n == 0) {
  4.             return 1;
  5.         }
  6.         else if (n == 1) {
  7.             return m;
  8.         }
  9.        
  10.         return m *= power(m, n - 1);
  11.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement