Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. public class Raise {
  2.    
  3.     public static double recRaiseHalf(double x, int k) {
  4.         double y = (x * Math.floor(k / 2));
  5.         if(k == 0) {
  6.             return 1.0;
  7.         } else if(k % 2 == 0 ) {
  8.             x = (y * y);
  9.             return recRaiseHalf(x, k - 1);
  10.         } else {
  11.             x = (x * y * y);
  12.             return recRaiseHalf(x, k - 1);
  13.         }
  14.     }
  15.    
  16.     public static void main(String[] args) {
  17.         System.out.println(recRaiseHalf(43, 2));
  18.  
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement