fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(pow(2,8));
  13. }
  14.  
  15. static int pow (int a, int b) {
  16. if (b == 0) return 1;
  17. else {
  18. int x = 0;
  19. if (b % 2 == 1) {
  20. x = pow(a,b/2);
  21. x = x * x * a;
  22. System.out.println("b % 2 == 1");
  23. System.out.println(b);
  24. System.out.println(x);
  25.  
  26. } else {
  27. x = pow (a,b/2);
  28. x = x * x;
  29. System.out.println("b % 2 != 1");
  30. System.out.println(b);
  31. System.out.println(x);
  32. }
  33.  
  34. return x;
  35. }
  36. }
  37. }
Success #stdin #stdout 0.06s 2184192KB
stdin
Standard input is empty
stdout
b % 2 == 1
1
2
b % 2 != 1
2
4
b % 2 != 1
4
16
b % 2 != 1
8
256
256