P37

ninetynine.P37
object P37

P37 - calculate Euler's totient function phi(m) (improved).

Euler's so-called totient function phi(m) is defined as the number of positive integers r (1 <= r < m) that are coprime to m. We let phi(1) = 1.

From the definition of P34, we can see that phi(m) is equal to m * (1 - 1/p1) * (1 - 1/p2) * (1 - 1/p3) * ... where p1, p2, p3, ... are the prime factors of m.

Note that we need to use the primeFactors function from P36.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
P37.type

Members list

Value members

Concrete methods

def totient(m: Int): Int

Attributes

Returns

Euler's totient function phi(m)

Concrete fields

val logger: Logger