Friday, October 17, 2025
HomeLanguagesPython | sympy.primenu() method

Python | sympy.primenu() method

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:




# import primenu() method from sympy
from sympy.ntheory.factor_ import primenu
  
n = 24
  
# Use primenu() method 
primenu_n = primenu(n) 
      
print("Number of distinct prime factors of {} = {} ".format(n, primenu_n)) # 2 and 3


Output:

Number of distinct prime factors of 24 = 2  

Example #2:




# import primenu() method from sympy
from sympy.ntheory.factor_ import primenu
  
n = 2 * 3*7 * 11 * 13
  
# Use primenu() method 
primenu_n = primenu(n) 
      
print("Number of distinct prime factors of {} = {} ".format(n, primenu_n))  


Output:

Number of distinct prime factors of 6006 = 5 
Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS