Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Enter to numbers to satisfy K and N. 1< N< K");
- Console.WriteLine("K:");
- int K = int.Parse(Console.ReadLine());
- Console.WriteLine("N:");
- int N = int.Parse(Console.ReadLine());
- if (K < N || N < 1 || K<1)
- {
- Console.WriteLine("Something went wrong! This does not satisfy the condition! ");
- return;
- }
- int factorial = 1;
- for (int i = K - N + 1; i <= K; i++)
- {
- factorial *= i;
- if (i == K)
- {
- i = 2;
- while (i <= N)
- {
- factorial *= i;
- i++;
- }
- break;
- }
- }
- Console.WriteLine("\n The factorial is: {0}!*{1}!/{1}-{0} = {2}\n", N, K, factorial);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement