Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import random
- from math import factorial
- f = factorial
- def doTriangle(t):
- for a in range(0, t + 1):
- for b in range(0, a + 1):
- x = f(a) / (f(b) * f(a - b))
- print(int(x),end=" ")
- print("")
- print("Done!")
- def main():
- try:
- if len(sys.argv) == 2:
- doTriangle(int(sys.argv[1]))
- else:
- doTriangle(int(input("Compute up to: ")))
- except ValueError:
- x = int(random.randrange(2, 20))
- print("Invalid input, randomly chose " + str(x) + ".")
- doTriangle(x)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement