Euler's Totient Function counts the positive integers up to a given integer n that are relatively prime to n (relatively prime numbers are numbers that have only one common divisor - 1).
This is how Euler's function looks like:
The solution of the problem is reduced to one formula:
f(n) = (P1^B1 - P1^(B1 - 1))*(P2^B2 - P2^(B2 - 1)).....*(Pm^Bm - Pm^(Bm - 1)), where P are prime divisors of n and B are powers of divisors.
That's, to find f(n) we need
- to find prime divisors of n and powers of divisors
- to write fast power function
- for fast power function we need to write Bitset class
No comments:
Post a Comment