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("PLease enter two numbers to satisfy K and N (1<K<N");
- Console.WriteLine("K:");
- int K = int.Parse(Console.ReadLine());
- Console.WriteLine("N:");
- int N = int.Parse(Console.ReadLine());
- if (N < K || N < 1 || K < 1)
- {
- Console.WriteLine("Something went wrong! This does not satisy the condition");
- return;
- }
- int factorial = 1;
- for (int i = K + 1; i <= N; i++)
- {
- factorial *= i;
- }
- Console.WriteLine("\nThe factorial is: {0}!/{1}! = {2}\n", K, N, factorial);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement