Ackermann's Function in Java

      class Ack {
      
          static int ack(int m, int n) {
              if (m == 0)
                  return n+1;
              else if (n == 0)
                  return ack(m-1, 1);
              else
                  return ack(m-1, ack(m, n-1));
          }
      
          public static void main (String[] args) {
              int m = 3;
              int n = 9;
              if (args.length > 0)
                  m = Integer.parseInt (args[0]);
              if (args.length > 1)
                  n = Integer.parseInt (args[1]);
              System.out.println (ack (m, n));
          }
      }
    

For debugging: Click here to validate.