Skip to content

Instantly share code, notes, and snippets.

@sigmavirus24
Created August 10, 2014 13:21
Show Gist options
  • Save sigmavirus24/44885b92ce00e105b92e to your computer and use it in GitHub Desktop.
Save sigmavirus24/44885b92ce00e105b92e to your computer and use it in GitHub Desktop.
Pascal's Triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
1 7 21 35 35 21 7 1
1 8 28 56 70 56 28 8 1
# Source: https://twitter.com/raymondh/status/498316311013777408
from __future__ import print_function
from math import factorial as f
def main():
for n in range(9):
print(
''.join(
'%4d' % (f(n)/f(n-k)/f(k)) for k in range(0, n + 1)
).center(40)
)
if __name__ == '__main__':
main()
@mauricioabreu
Copy link

funny

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment