SHARE
TWEET

CSH2012 LAB12 pascal.py

calcpage Jun 1st, 2013 176 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. #pascal.py     MrG    2013.0524
  3.  
  4. def pascal(n,r):
  5.     if n==r or r==0:
  6.         return 1
  7.     return pascal(n-1,r)+pascal(n-1,r-1)
  8.  
  9. for n in range(8):
  10.     for r in range(n+1):
  11.         print pascal(n,r),"\t",
  12.     print
RAW Paste Data
Want to get better at Python?
Learn to code Python in 2017
Pastebin PRO Summer Special!
Get 40% OFF on Pastebin PRO accounts!
Top