aboutsummaryrefslogtreecommitdiffstats
path: root/ack.c
diff options
context:
space:
mode:
authorEliteTK <tomasz.kramkowski@gmail.com>2014-07-10 22:36:56 +0100
committerEliteTK <tomasz.kramkowski@gmail.com>2014-07-10 22:36:56 +0100
commitb60441758f9832a67f60e51a4ee92d16b166b9fb (patch)
tree7388adc9743181457834cc5eed95e3c452266ab0 /ack.c
parenta26f2837166f7232d13322e013883ed003d46f27 (diff)
parenta8609ccd901b1942e862c14205026d841e640add (diff)
downloadc-stuff-b60441758f9832a67f60e51a4ee92d16b166b9fb.tar.gz
c-stuff-b60441758f9832a67f60e51a4ee92d16b166b9fb.tar.xz
c-stuff-b60441758f9832a67f60e51a4ee92d16b166b9fb.zip
Merge branch 'master' of https://github.com/EliteTK/c-stuff
Conflicts: xcb.c
Diffstat (limited to 'ack.c')
-rw-r--r--ack.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/ack.c b/ack.c
new file mode 100644
index 0000000..65010c8
--- /dev/null
+++ b/ack.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+
+int ack(m, n)
+int m, n;
+{
+ int ans;
+ if (m == 0) ans = n + 1;
+ else if (n == 0) ans = ack(m - 1, 1);
+ else ans = ack(m - 1, ack(m, n - 1));
+ return (ans);
+}
+
+int main(argc, argv)
+int argc; char **argv;
+{
+ int i, j;
+ for (j = 0; i <= 5; i++)
+ for (j = 0; j <= 5; j++)
+ printf("ackerman(%d, %d) is: %d\n", i, j, ack(i, j));
+ return 0;
+}