Not much going on. Generate a sequence with all the numbers between 1 and n - 1 which greatest common denominator with n is one and get the length of that sequence.
Tests
classFractionSpecextendsFunSuite{test("properFractions"){assert(properFractions(1)==0,"No proper fractions with denominator 1")assert(properFractions(2)==1,"1 proper fraction with denominator 2")assert(properFractions(5)==4,"4 proper fractions with denominator 5")assert(properFractions(15)==8,"8 proper fractions with denominator 15")assert(properFractions(25)==20,"20 proper fractions with denominator 25")}}
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Scala
Not much going on. Generate a sequence with all the numbers between
1
andn - 1
which greatest common denominator withn
is one and get the length of that sequence.Tests