Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace NchooseKcount
- {
- class Program
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int k = int.Parse(Console.ReadLine());
- decimal result = Binom(n, k);
- Console.WriteLine(result);
- }
- private static decimal Binom(int n, int k)
- {
- if (k > n)
- {
- return 0;
- }
- if (k == 0 || k == n)
- {
- return 1;
- }
- return Binom(n - 1, k - 1) + Binom(n - 1, k);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement