The totient function phi(n), the subject of Cody Problems 656 and 50182, gives the number of integers smaller than n that are relatively prime to n--that is, that share no common factors with n other than 1. Therefore, phi(9) = 6 because 1, 2, 4, 5, 7, and 8 (i.e., six numbers less than 9) are relatively prime to 9.
The unitary totient function phi*(n) is defined in terms of the function gcd*(k,n), which is the largest divisor of k that is also a unitary divisor of n. Then the unitary totient function gives the number of k (with 1 <= k <= n) such that gcd*(k,n) = 1. For example, phi*(9) = 8 because the unitary divisors of 9 are 1 and 9. Therefore, for 1, 2, 3,...,8, the largest divisors that are also unitary divisors of 9 are 1-8.
Write a function to compute the unitary totient function.

Solution Stats

11 Solutions

7 Solvers

Last Solution submitted on Feb 03, 2026

Last 200 Solutions

Problem Comments

Solution Comments

Show comments
Loading...