CSharp examples for Data Structure Algorithm:Algorithm
Calculates N!/K! for given N and K (1<K<N).
using System;/*from w ww . j a v a2 s . c o m*/ using System.Numerics; class NDivByK { static void Main() { Console.WriteLine("Enter number: "); int n = int.Parse(Console.ReadLine()); int k = int.Parse(Console.ReadLine()); BigInteger Nfac = 1; BigInteger Kfac = 1; BigInteger result; for (int i = 1; i <= n; i++) { Nfac = Nfac * i; } for (int i = 1; i <= k; i++) { Kfac = Kfac * i; } result = Nfac / Kfac; Console.WriteLine(result); } }