-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathchallenge1b.py
More file actions
42 lines (34 loc) · 737 Bytes
/
Copy pathchallenge1b.py
File metadata and controls
42 lines (34 loc) · 737 Bytes
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
# Again create pascal's triangle to as many rows as a user requests
# This time print the numbers to the commandline (without turtles)
# E.G.:
#1
#11
#121
#1331
# Coded by Saffa. It is now working.
import math
def exa(z):
n = z
r = 0
example = ""
while r <= n:
fact_n = math.factorial(n)
fact_r = math.factorial(r)
sub = n - r
fact_sub = math.factorial(sub)
answer = (fact_n / (fact_sub * fact_r))
example += str(answer) + " "
r += 1
print example
def main():
n = int(raw_input(" Enter n: "))
y = n
y += 1
z = []
for i in range(0, n + 1):
y -= 1
z.append(y)
z.reverse()
for i in z:
exa(i)
main()