[Homework] Problem 7. Calculate N! / (K! * (N-K)!)
Console.Write("Enter N: ");
            int N = int.Parse(Console.ReadLine());
            Console.Write("Enter K: ");
            int K = int.Parse(Console.ReadLine());
            int resultN = N;
            int resultK = K;
            int resultNK = N - K;
            if (1 < K || K < N || N < 100)
            {
                for (int i = 1; i < N; i++)
                {
                    resultN = resultN * i;
                }
                for (int i = 1; i < K; i++)
                {
                    resultK = resultK * i;
                }
                for (int i = 1; i < N - K; i++)
                {
                    resultNK = resultNK * i;
                }
                Console.WriteLine(resultN / (resultK*(resultNK)));
            }
            else
            {
                Console.WriteLine("Try again");
            }
In combinatorics, the number of ways to choose k different members out of a group of n different elements (also known as the number of combinations) is calculated by the following formula:
For example, there are 2598960 ways to withdraw 5 cards out of a standard deck of 52 cards. Your task is to write a program that calculates n! / (k! * (n-k)!) for given n and k (1 < k < n < 100). Try to use only two loops.
Това е условието. Това са примерите:
| N | K | NK | 
| 3 | 2 | 3 | 
| 4 | 2 | 6 | 
| 10 | 6 | 210 | 
| 52 | 5 | 2598960 | 
С първите три примера работи но когато пробвам последния програмата спира и не знам защо. Може ли някои да ми каже къде греша защото аз незнам.