Check if Euler Totient Function is same for a given number and twice of that number | Function to find the Euler 's Totient Function ; Initialize result as N ; Consider all prime factors of n and subtract their multiples from result ; Return the count ; Function to check if phi ( n ) is equals phi ( 2 * n ) ; Driver Code
function phi ( n ) { let result = 1 ; for ( let p = 2 ; p < n ; p ++ ) { if ( __gcd ( p , n ) == 1 ) { result ++ ; } } return result ; } function sameEulerTotient ( n ) { return phi ( n ) == phi ( 2 * n ) ; } function __gcd ( a , b ) { return b == 0 ? a : __gcd ( b , a % b ) ; } let N = 13 ; if ( sameEulerTotient ( N ) ) document . write ( " " ) ; else document . write ( " " ) ;