Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int k = int.Parse(Console.ReadLine());
- if (1 < k && k < n && n < 100)
- {
- int result1 = 1;
- int result2 = 1;
- int result;
- int count = 1;
- for (int index = n - k + 1; index <= n; index++)
- {
- result1 *= index;
- if (count <= k)
- {
- result2 *= count;
- count++;
- }
- }
- result = result1 / result2;
- Console.WriteLine(result);
- }
- else
- {
- Console.WriteLine("out of range");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement