Home python Euler function and mutually simple numbers

Euler function and mutually simple numbers

Author

Date

Category

Euler function
The natural number n is given, determine the amount of natural numbers smaller than N and mutually simple with n.
Input data
It is given a natural number N≤10 9 .

output
Display φ (n).

Enter
ten
output
4
I do not understand how to solve this task!


Answer 1, Authority 100%

That’s, I even managed to write 🙂

defi (n):
  f = n;
  IF N% 2 == 0:
    While N% 2 == 0:
      n = n // 2;
    f = f // 2;
  i = 3.
  While I * i & lt; = n:
    IF N% i == 0:
      While N% i == 0:
        n = n // i;
      f = f // i;
      f = f * (i-1);
    i = i + 2;
  IF N & GT; 1:
    f = f // n;
    f = f * (n-1);
  RETURN F;
Print (Fi (int (Input ())));

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions