Python| sympy.composite() 方法
在sympy.composite()方法的帮助下,我们可以找到第n 个合数,该合数索引为Composite(1) = 4、composite(2) = 6等。
Syntax: composite(n)
Parameter:
n – It denotes the nth composite number.
Returns: Returns the nth composite number.
示例 #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