Rename files, add headers, fix typos in 13
This commit is contained in:
parent
a6b4a427e0
commit
954069159a
8 changed files with 31 additions and 2 deletions
|
|
@ -1,41 +0,0 @@
|
|||
def createTriange(numRows):
|
||||
if numRows < 0:
|
||||
return
|
||||
else:
|
||||
for i in range(numRows+1):
|
||||
spaces = (" "*(numRows-i))
|
||||
nums = f"{createRow(i)}"
|
||||
print(spaces + nums + spaces)
|
||||
|
||||
|
||||
def createRow(currentRow):
|
||||
row = []
|
||||
|
||||
for i in range(currentRow + 1):
|
||||
coefficient = getbinomial(currentRow, i)
|
||||
row.append(coefficient)
|
||||
|
||||
result = " ".join(map(str, row))
|
||||
|
||||
return result
|
||||
|
||||
def getbinomial(n, k):
|
||||
numerator = factorial(n)
|
||||
denominator = factorial(k) * factorial(n - k)
|
||||
return numerator // denominator
|
||||
|
||||
|
||||
def factorial(number):
|
||||
if number < 0:
|
||||
return
|
||||
elif number > 1:
|
||||
number *= factorial(number - 1)
|
||||
return number
|
||||
else:
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
createTriange(10)
|
||||
|
||||
|
||||
Loading…
Reference in a new issue