using System using System Collections Generic using System Linq using

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int switchcase = 1, k = 10, n = 5;
switch (switchcase)
{
case 1:
int A = factorial (n) / factorial (n - k);
Console.WriteLine(A);
break;
case 2:
int B = 1;
for (int i = 1; i < k; i++)
{
B = B * n;
}
Console.WriteLine(B);
break;
case 3:
n = factorial (n);
k = factorial (k);
int l = factorial(n - k);
l = n / (k * l);
Console.WriteLine(l);
break;
case 4:
int C = factorial(n + k - 1) / (factorial(n) * factorial(k - 1));
Console.WriteLine(C);
break;
case 5:
int D = factorial(n);
Console.WriteLine(D);
break;
case 6:
int E = factorial(n);
for (int i = 1; i < k; i++)
{
E = E / factorial(i);
}
Console.WriteLine("Введено неверно");
break;
}
}
public static int factorial(int n)
{
int res = 1;
for (int i = 2; i < n; i++)
{
res = res * i;
}
return res;
}
}
}