# Ackermann Function

## Recommended Posts

Hello,

I'm new here and also new to Computer Sciences. I'm a first semester university student and so far we're only doing mathematics and a lot of theoretical background on computer sciences.

So in one of my assignments we have the option for 120 bonus points but it's pretty much exclusive to those who have programmed before and I find this quite unfair. We complained, so at least one of our tutors helped us in recommending some code snippets. But since I have never coded before I'm totally lost and I really would want to have at least a part of those bonus points.

The question is:

"Calculate the Ackermann Function A for A(8,6). Write down all intermediate data."

Our tutor gave us this hint: I just have no idea what I should do with this?

class Ackermann
{
public static long ackermann( long n, long m )
{
if ( n == 0 )
return m + 1;
else

if ( m == 0 )
return ackermann( n - 1, 1 );
else
return ackermann( n - 1, ackermann(n, m - 1) );

}
public static void main( String args[] )
{
int x = 2,
y = 2;
System.out.println( "ackermann(" + x + "," + y + ")=" + ackermann(x,y) );
}
}

One guy in another study group tried a c++ code, but I don't have the source and I wouldn't even have a clue how to use it...

Help is really appreciated!

• 1

##### Share on other sites

Do you know this website?

Wolfram

By the way (BTW) since this is coursework we can't do it for you but we can hint and guide.

However you must play your part and show some working.

Also this should be in homework help.

##### Share on other sites
1 hour ago, MauraF said:

Our tutor gave us this hint: I just have no idea what I should do with this?

I would ignore most of it (creating a Class to calculate a single function: stupid overkill).

If you know nothing about programming, then you have quite a challenge. Start by finding some tutorials online to learn the basics. All you need to do is learn how to write a function (a "sub-program" that calculates a value for you) and print the result. I would choose a language like Python which is interactive and allows you to try things out quickly. You don't need to get to grips with compilers or any of that nonsense.

Once you are comfortable with the basics (write a program with a function to calculate the square of a number, for example) then you can translate the "ackerman" function from his example into Python (or whatever you choose to use).

##### Share on other sites

And use wolfram alpha to provide some known example results to test your program.

• 1

##### Share on other sites

Hi all,

first I want to thank you for your help.

Unfortunately, I won't be able to learn any coding language within the time we have for the assignment. We got it on Monday and have to hand it in on Friday.

I would be glad to just get a small percentage of the bonus points, and I hope I can do that by calculating it by hand?

##### Share on other sites
5 minutes ago, MauraF said:

I hope I can do that by calculating it by hand?

That might be a challenge. You could try this: https://www.wolframalpha.com/input/?i=Ackerman(8,6)

See how many times you can click "More" in the expansion section ...

Just looking at the way the value of the function "explodes" for even small values of the first argument, this is not a trivial programming exercise. You would need to use a library that can handle arbitrarily large integers. And a very large amount of paper to print out the result!

##### Share on other sites

Yeah, it definitely is a nightmare task. We can't print out the result either, all must be handwritten. I think it's just to see who actually tries to do it. The more you do, the more points you get. :-/

##### Share on other sites

How much paper do you have?

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account