You will compute twice: by counting, and by the product formula. Then you will test Euler's theorem on many cases.
The idea. Counting checks every from to with gcd. The formula needs the primes of : start with result = n and, for each prime of , subtract result // p.
Your tasks.
phi_count(n). Count the from to with gcd(k, n) == 1.phi_formula(n). Use the primes from primes_of(n) and the rule above.euler_holds(a, n). Return True when , using pow with three arguments.Run your code once to unlock the worked solution.
Have you tried it?
Do the tasks in the editor first, and run the checker after each one. Its hints help when a check fails. When you are ready, compare your code with this solution.
Log in to join the discussion.
Loading…