# Python | sympy.totient() method

With the help of sympy.totient() method, we can find Euler totient function or phi(n) of a given integer. Euler totient function is the number of positive integers less than or equal to a given integer that are relatively prime to it. In other words, it is the number of integers k in the range 1 <= k <= n for which the greatest common divisor gcd(n, k) is equal to 1.

Syntax: totient(n)

Parameter:
n – It denotes an integer.

Returns: Returns the number of integers less than or equal to that integer n that are relatively prime to it.

Example #1:

 `# import totient() method from sympy ` `from` `sympy.ntheory.factor_ ``import` `totient ` ` `  `n ``=` `24` ` `  `# Use totient() method  ` `totient_n ``=` `totient(n)  ` `     `  `print``(``"phi({}) =  {} "``.``format``(n, totient_n)) ``# 1 5 7 11 13 17 19 23 `

Output:

```phi(24) =  8
```

Example #2:

 `# import totient() method from sympy ` `from` `sympy.ntheory.factor_ ``import` `totient ` ` `  `n ``=` `19` ` `  `# Use totient() method  ` `totient_n ``=` `totient(n)  ` `     `  `print``(``"phi({}) =  {} "``.``format``(n, totient_n)) `

Output:

```phi(19) =  18
```

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.