Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication10
  8. {
  9. class Program
  10. {
  11. static int maccarthy(int n)
  12. {
  13. if (n > 100) return n - 10;
  14. else return maccarthy(n + 11);
  15. }
  16. static int akermann(int m, int n)
  17. {
  18. if (m == 0) return n + 1;
  19. else
  20. if (n == 0) return akermann(m - 1, 1);
  21. else return akermann(m - 1, akermann(m, n - 1));
  22.  
  23.  
  24.  
  25. }
  26. static void Main(string[] args)
  27. {
  28. bool ok; int x, y;
  29. do
  30. {
  31. Console.Write("n = ");
  32. ok = Int32.TryParse(Console.ReadLine(), out x);
  33. } while (!ok);
  34.  
  35. Console.WriteLine(maccarthy(x));
  36. do
  37. {
  38. Console.Write("m = ");
  39. ok = Int32.TryParse(Console.ReadLine(), out y);
  40. } while (!ok);
  41. Console.WriteLine(akermann(y, x));
  42. Console.ReadKey();
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement