/* The Great Win32 Language Shootout http://dada.perl.it/shootout/ 
   contributed by Isaac Gouy (Nice novice)

To compile:	
   nicec --sourcepath=.. -d=. -a ackermann.jar ackermann

To run:
   java -jar ackermann.jar 8
*/


void main(String[] args){

   // NOTE: the type of n will be 
   //       inferred by the compiler

   let n = toSingleInt(args);   
   println("Ack(3," + n + "): " + ack(3,n)); 
}


int ack(int m, int n){
   if (m == 0) return n + 1;
   if (n == 0) return ack(m-1, 1);
   return ack(m-1, ack(m, n-1)); 
}


int toSingleInt(String[] s){
   try { return Integer.parseInt(s[0]); }
   catch (Exception e){ return 1; } }