Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. using System;
  2.  
  3. namespace LambdaFac
  4. {
  5. using T = Func<Func<dynamic, Func<int, int>>, Func<int, int>>;
  6. static class Program
  7. {
  8. static void Main()
  9. {
  10. var fac = ((T) (self_fix => self_fix(self_fix)))(f => x => x <= 1 ? 1 : x * f(f)(x - 1));
  11. for (var i = 0; i < 10; i++)
  12. {
  13. Console.WriteLine($"the factorial of {i} is {fac(i)}");
  14. }
  15.  
  16. Console.ReadLine();
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement