Python | sympy.primenu() method
Last Updated :
17 Sep, 2019
With the help of sympy.primenu() method, we can calculate the number of distinct prime factors for a given positive integer.
Syntax: primenu(n)
Parameter:
n – It denotes an integer.
Returns: Returns the number of distinct prime factors for the given positive integer.
Example #1:
from sympy.ntheory.factor_ import primenu
n = 24
primenu_n = primenu(n)
print ( "Number of distinct prime factors of {} = {} " . format (n, primenu_n))
|
Output:
Number of distinct prime factors of 24 = 2
Example #2:
from sympy.ntheory.factor_ import primenu
n = 2 * 3 * 7 * 11 * 13
primenu_n = primenu(n)
print ( "Number of distinct prime factors of {} = {} " . format (n, primenu_n))
|
Output:
Number of distinct prime factors of 6006 = 5
Share your thoughts in the comments
Please Login to comment...