With the help of sympy.primenu() method, we can calculate the number of distinct prime factors for a given positive integer.

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
```

My Personal Notes arrow_drop_up

Coder Machine Learner Social Activist Vocalist

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :

Be the First to upvote.

Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.