Advertisement
korobushk

power

Apr 19th, 2021
799
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public class app {
  2.     public static void main(String[] args) {
  3.         var result = power(10,10);
  4.         System.out.println(result);
  5.     }
  6.  
  7.     public static int power(int base, int exp) {
  8.         if(exp<0){
  9.            return -1;
  10.         }
  11.         if(exp==0||exp==1){
  12.             return base;
  13.         }
  14.  
  15.         return base * power(base, exp - 1);
  16.     }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement