Python | sympy.partition() method
sympy.partition()
Partition number
partition(n) -
pn
n
pn
Syntax: partition(n) Parameter: n – It denotes the number upto which partition number is to be calculated. Returns: Returns the nth partition number.
Example #1:
# import sympy from sympy import * n = 7 print ( "Value of n = {}" . format (n)) # Use sympy.partition() method nth_partition = partition(n) print ( "Value of nth partition number : {}" . format (nth_partition)) |
Output:
Value of n = 7 Value of nth partition number : 15
Example #2:
# import sympy from sympy import * n = 10 print ( "Value of n = {}" . format (n)) # Use sympy.partition() method n_partition = [partition(x) for x in range ( 1 , 11 )] print ( "N partition number are : {}" . format (n_partition)) |
Output:
Value of n = 10 N partition number are : [1, 2, 3, 5, 7, 11, 15, 22, 30, 42]
Contact Us