Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Write a program that calculates N!*K! / (K-N)! for given N and K (1<N<K).
- */
- using System;
- class MoreFactorials
- {
- static void Main()
- {
- Console.WriteLine("Enter two numbers k>n>1: ");
- int n = int.Parse(Console.ReadLine());
- int k = int.Parse(Console.ReadLine());
- int result = 1;
- if ((n>1) && (k>n))
- {
- for (int i = k, j = 1; i > k - n; i--, j++)
- {
- result *= i*j;
- }
- Console.WriteLine(result);
- }
- else
- {
- Console.WriteLine("Invalid numbers");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement