Advertisement
callumbinner22

task 6

Nov 6th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.93 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             Console.WriteLine("PLease enter two numbers to satisfy K and N (1<K<N");
  14.             Console.WriteLine("K:");
  15.             int K = int.Parse(Console.ReadLine());
  16.             Console.WriteLine("N:");
  17.             int N = int.Parse(Console.ReadLine());
  18.  
  19.             if (N < K || N < 1 || K < 1)
  20.             {
  21.                 Console.WriteLine("Something went wrong! This does not satisy the condition");
  22.                 return;
  23.             }
  24.             int factorial = 1;
  25.             for (int i = K + 1; i <= N; i++)
  26.             {
  27.                 factorial *= i;
  28.             }
  29.             Console.WriteLine("\nThe factorial is: {0}!/{1}! = {2}\n", K, N, factorial);
  30.  
  31.      
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement