Advertisement
Guest User

Factorial Division

a guest
Feb 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 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 Functions
  8. {
  9.     class Program
  10.     {
  11.         static private double Factorial(double n)
  12.         {
  13.             if (n == 1 || n == 0)
  14.             {
  15.                 return 1;
  16.             }
  17.             else
  18.                 return n * Factorial(n - 1);
  19.         }
  20.         private static void Main(string[] args)
  21.         {
  22.             double n = double.Parse(Console.ReadLine());
  23.             double k = double.Parse(Console.ReadLine());
  24.             double result = Factorial(n) / Factorial(k);
  25.             Console.WriteLine($"{result:F2}");
  26.         }
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement