CS174: Ackermann Function Exercise (2 Points)

C++ frontend developed by, Professor Tralie, adopted from code by Todd Fleming. Canvas Autograder Developed by Professor Tralie and Professor Mongan.


Exercise Goals

The goals of this exercise are:
  1. Work with recursive functions in C++
  2. Implement the Ackermann function using recursive calls
The Ackermann function is a recursive function that grows notoriously quickly. The definition is as follows:

Fill in the code below to compute this function using recursive calls.

Student Code

#include <stdio.h> int A(int m, int n) { int ret = 0; // TODO: Fill this in return ret; }

Main Area

int main() { printf("%i.", A(0, 0)); printf("%i.", A(1, 1)); printf("%i.", A(2, 2)); printf("%i.", A(3, 2)); printf("%i.", A(3, 4)); printf("\n"); }

Compiler Feedback

Program Output

Click compile to compile your code. If it succeeds with no syntax errors, then click run to run your code. If it passes the tests, it will automatically submit to Canvas and send you an e-mail. You must be connected to the Ursinus Network for submission to be successful! You will receive a copy of your code via e-mail, so you'll know that it was submitted if you receive that e-mail!
Please Enter your Ursinus netid before clicking run. This is not your ID number or your email. For example, my netid is ctralie (non Ursinus students can simply enter their name to get this to run, but they won't get an e-mail record or any form of credit)

Netid