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 5
5
from . import factorial
6
6
from . import lcm
7
7
from . import lcm_using_gcd
8
+ from . import pascals_triangle
8
9
from . import sieve_of_eratosthenes
9
10
10
11
__all__ = [
11
12
'conversion' ,
12
13
'factorial' ,
13
14
'lcm_using_gcd' ,
14
15
'lcm' ,
16
+ 'pascals_triangle' ,
15
17
'sieve_of_eratosthenes'
16
18
]
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