Combinatorics

 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
print '-------------------------\n'
print 'Combinatorics by nikoTM\n'
print '-------------------------\n'
print '''
1. A(Repetition)
2. C(Permutation)
'''
def factor(n):
i=0
x=1
while i<n:
x=x*(n-i)
i=i+1
return x
def A():
global a, b
r=0
if a > b :
r=factor(a)/factor(a-b)
return r
else:
print 'A must be bigger than B!'
return 'fuck..'
def C():
global a, b
r=0
if a > b :
r=factor(a)/(factor(b)*factor(a-b))
return r
else:
print 'A must be bigger than B!'
return 'fuck..'
while True:
t = int(raw_input("Type: "))
if t == 1:
a = int(raw_input("N: "))
b = int(raw_input("M: "))
print A()
elif t == 2:
a = int(raw_input("N: "))
b = int(raw_input("M: "))
print C()
else:
print "1 or 2!"