week1/05-sum_of_divisors
2023-09-20 09:53:04 -04:00
..
2023-09-20 09:53:04 -04:00
2023-09-20 09:53:04 -04:00

WTF - Write Totatives Finder

The divisors of a number are those numbers that divide it evenly; for example, the divisors of 60 are 1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30, and 60. The sum of the divisors of 60 is 168, and the number of divisors of 60 is 12.

The totatives of a number are those numbers less than the given number and coprime to it. Two numbers are coprime if they have no common factors other than 1.

For example, the totatives of 30 are 1, 7, 11, 13, 17, 19, 23, and 29.

The number of totatives of a given number is called its totient. As you can see above, the totient of 30 is 8.

Your task is to write a small library of five functions that compute the divisors of a number, the sum and number of its divisors, the totatives of a number, and its totient.

Hint: The functions can call each other!