File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 55from . import factorial
66from . import lcm
77from . import lcm_using_gcd
8+ from . import pascals_triangle
89from . import sieve_of_eratosthenes
910
1011__all__ = [
1112 'conversion' ,
1213 'factorial' ,
1314 'lcm_using_gcd' ,
1415 'lcm' ,
16+ 'pascals_triangle' ,
1517 'sieve_of_eratosthenes'
1618]
17-
Original file line number Diff line number Diff line change 1+ '''
2+ Author: OMKAR PATHAK
3+ Created at: 26th August 2017
4+ '''
5+
6+ def pascals_triangle (n ):
7+ '''
8+ :param n: total number of lines in pascal triangle
9+
10+ Pascal’s triangle is a triangular array of the binomial coefficients.
11+ Following are the first 6 rows of Pascal’s Triangle (when n = 6)
12+ 1
13+ 1 1
14+ 1 2 1
15+ 1 3 3 1
16+ 1 4 6 4 1
17+ 1 5 10 10 5 1
18+ '''
19+
20+ for line in range (1 , n + 1 ):
21+ C = 1
22+ for i in range (1 , line + 1 ):
23+ print (C , end = ' ' )
24+ C = C * (line - i ) // i
25+ print ()
You can’t perform that action at this time.
0 commit comments