Python sympy.composite()方法
在sympy.composite()方法的帮助下,我们可以找到第n个复合数,复合数的索引为composite(1)=4,composite(2)=6 ,等等。
语法: composite(n)
参数 :
n –它表示第n个复合数。
返回:返回第n个复合数。
示例 #1:
# import sympy
from sympy import composite
n = 5
# Use composite() method
nth_composite = composite(n)
print("The {}th composite is {}".format(n, nth_composite))
输出:
The 5th composite is 10
示例 #2:
# import sympy
from sympy import composite
n = 25
# Use composite() method
nth_composite = composite(n)
print("The {}th composite is {}".format(n, nth_composite))
输出:
The 25th composite is 38