Related Articles
Python | sympy partitions.RGS_generalized() method
• Last Updated : 27 Aug, 2019

With the help of `sympy.combinatorics.partitions.RGS_generalized()` method, we can get the m+1 unrestricted growth string and return a matrix by using `sympy.combinatorics.partitions.RGS_generalized()` method.

Syntax : `sympy.combinatorics.partitions.RGS_generalized(m)`
Return : Return a matrix of size m+1.

Example #1 :
In this example we can see that by using `sympy.combinatorics.partitions.RGS_generalized()` method, we are able to get the unrestricted growth string and return a matrix of size m+1.

 `# import sympy and RGS_generalized``from` `sympy.combinatorics.partitions ``import` `RGS_generalized``from` `sympy ``import` `*``   ` `# Using sympy.combinatorics.partitions.RGS_generalized() method``gfg ``=` `RGS_generalized(``3``)`` ` `print``(gfg)`

Output :

Matrix(
[ [1, 1, 1, 1],
[1, 2, 3, 0],
[2, 5, 0, 0],
[5, 0, 0, 0] ])

Example #2 :

 `# import sympy and RGS_generalized``from` `sympy.combinatorics.partitions ``import` `RGS_generalized``from` `sympy ``import` `*``   ` `# Using sympy.combinatorics.partitions.RGS_generalized() method``gfg ``=` `RGS_generalized(``6``)`` ` `print``(gfg)`

Output :

Matrix(
[ [1, 1, 1, 1, 1, 1, 1],
[1, 2, 3, 4, 5, 6, 0],
[2, 5, 10, 17, 26, 0, 0],
[5, 15, 37, 77, 0, 0, 0],
[15, 52, 151, 0, 0, 0, 0],
[52, 203, 0, 0, 0, 0, 0],
[203, 0, 0, 0, 0, 0, 0] ])

Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course

My Personal Notes arrow_drop_up