Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Raise {
- public static double recRaiseHalf(double x, int k) {
- double y = (x * Math.floor(k / 2));
- if(k == 0) {
- return 1.0;
- } else if(k % 2 == 0 ) {
- x = (y * y);
- return recRaiseHalf(x, k - 1);
- } else {
- x = (x * y * y);
- return recRaiseHalf(x, k - 1);
- }
- }
- public static void main(String[] args) {
- System.out.println(recRaiseHalf(43, 2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement