Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 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 FactorialFunction
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.WriteLine("Recursive Factorial");
  14. Console.WriteLine("\n");
  15. Console.WriteLine("Enter the number to be processed");
  16. int N = Convert.ToInt32(Console.ReadLine());
  17. int v=fact(N);
  18. Console.WriteLine("\n");
  19. Console.WriteLine("THe factorial of given number is:{0}", v);
  20. Console.ReadLine();
  21.  
  22. }
  23. static public int fact(int n)
  24. {
  25. int i,val=1;
  26. if (n == 1)
  27. return n;
  28. else
  29. {
  30. for (i = n; i >0; i--)
  31. {
  32. val = val * i;
  33. }
  34.  
  35. }
  36. return val;
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement