// $Id: ackermann.java,v 1.5 2001/11/17 17:20:39 doug Exp $ // http://www.bagley.org/~doug/shootout/ //** This copy courtesy of http://www.kano.net/javabench/ //** finalize Ack //** Added Timer() code public class ackermann { public static void main(String[] args) { long start = System.currentTimeMillis(); int num = Integer.parseInt(args[0]); System.out.println("Ack(3," + num + "): " + Ack(3, num)); long end = System.currentTimeMillis(); System.out.println("Time: " + (end - start) + " ms"); } public static final int Ack(int m, int n) { return (m == 0) ? (n + 1) : ((n == 0) ? Ack(m-1, 1) : Ack(m-1, Ack(m, n - 1))); } }