Proper Fractions Medium

+100 PTS

Before you start the test, check out our tutorial challenge

  • TYPE CODE PRACTICE CHALLENGE
  • LANGUAGES C++, C#, JAVA, JAVASCRIPT AND 6 MORE
    LANGUAGES C++, C#, JAVA, JAVASCRIPT, PHP, PYTHON, PYTHON2, RUBY, SWIFT, TYPESCRIPT
  • TIME ~25MIN

Proper Fractions

Challenge outline

Hello and welcome to the challenge!


Write a code which checks how many proper fractions you can make using the given number d as a denominator. By a proper fraction we consider such a fraction n/d that GCD(n,d) = 1 (where GCD stands for greatest common divisor).

Examples

  • solve(1) -> 0
  • solve(2) -> 1
  • solve(15) -> 8

Input

  • the given number d

Output

  • the amount of proper fractions we can make using the given number d as a denominator


You can solve this programming contest in C++, C#, Ruby, JavaScript, Python and many other languages. If you want, you can also take part in other November 2019 competitions. Below you can find some of them:



Have fun and good luck! :)