question about Ackermann function

Posted by davit-datuashvili on Stack Overflow See other posts from Stack Overflow or by davit-datuashvili
Published on 2010-05-29T15:52:49Z Indexed on 2010/05/29 16:02 UTC
Read the original article Hit count: 162

Filed under:

i am doing to write recursive program which calculates Ackemann function

http://en.wikipedia.org/wiki/Ackermann_function

here is code

public class Ackermann{

public static long ackermann( long m,long n){
return 
      (m==0)? n+1:
 (m>0 && n==0)? ackermann(m-1,1):
   (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); 







}


public static void main(String[]args){

long m=4;
long  n=2;
System.out.println(ackermann(m,n));


}
}

but it shows me mistakes

Ackermann.java:7: : expected
   (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); 
                                                 ^
Ackermann.java:7: ';' expected
   (m>0 && n>0)? ackermann(m-1, ackermann(m,n-1)); 
                                                  ^
Ackermann.java:18: illegal start of expression
public static void main(String[]args){
^
Ackermann.java:18: ';' expected
public static void main(String[]args){
      ^
Ackermann.java:18: illegal start of expression
public static void main(String[]args){
              ^
Ackermann.java:18: ';' expected
public static void main(String[]args){
                       ^
Ackermann.java:18: ';' expected
public static void main(String[]args){
                                    ^
Ackermann.java:26: reached end of file while parsing
}
 ^
8 errors

please help

© Stack Overflow or respective owner

Related posts about java