PY
py
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
"""
IN THE INPUT BOX YOU HAVE TO WRITE AN OPTION THEN THE 2 NUMBERS YOU WANT TO PERMUTATE OR COMBINATE(TO SEPRATE THEM U HAVE TO GO TO ANOTHER LINE)
"""
user_input = str(input())
# Permutation
if user_input == "permutation" or user_input == "perm":
x = int(input())
y = int(input())
def factorial(x):
if x == 1:
return 1
else:
return x * factorial(x-1)
def factorial(y):
if y == 1:
return 1
else:
return y * factorial(y-1)
result = factorial(x)/factorial(y)
print ("The permutation of",x, "and",y, "is",round(result, 9))
# combination
elif user_input=="combination" or user_input == "comb":
x = int(input())
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run