Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication10
- {
- class Program
- {
- static int maccarthy(int n)
- {
- if (n > 100) return n - 10;
- else return maccarthy(n + 11);
- }
- static int akermann(int m, int n)
- {
- if (m == 0) return n + 1;
- else
- if (n == 0) return akermann(m - 1, 1);
- else return akermann(m - 1, akermann(m, n - 1));
- }
- static void Main(string[] args)
- {
- bool ok; int x, y;
- do
- {
- Console.Write("n = ");
- ok = Int32.TryParse(Console.ReadLine(), out x);
- } while (!ok);
- Console.WriteLine(maccarthy(x));
- do
- {
- Console.Write("m = ");
- ok = Int32.TryParse(Console.ReadLine(), out y);
- } while (!ok);
- Console.WriteLine(akermann(y, x));
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement