human
Highly Totient Number | Function to find euler totient number.
Consider all prime factors of n and subtract their multiples from result.
Check if p is a prime factor ..
If yes , then update n and result.
If n has a prime factor greater than sqrt ( n ) ( There can be at - most one such prime factor ).
Function to find first n highly totient numbers.
Count of Highly totient numbers and value of count of phi of previous numbers.
Store all the values of phi ( x ) upto 10 ^ 5 with frequencies.
If count is greater than count of previous element.
Display the number.
Store the value of phi.
Driver code.
Function call"
How can the above be solved in Python?
assistant
#Here is code to highly Totient Number and the other steps required.
 def phi ( n ) :
	p = 2
	while ( p * p <= n ) :
		if ( n % p == 0 ) :
			while ( n % p == 0 ) :
				n //= p ;
			result -= ( result // p ) ;
		p += 1
	if ( n > 1 ) :
		result -= ( result // n ) ;
	return result ;
def Highly_Totient ( n ) :
	count = 0
	p_count = - 1
	mp = dict ( )
	i = 1
	while i < 100000 :
		tmp = phi ( i )
		if tmp not in mp :
			mp [ tmp ] = 0
		mp [ tmp ] += 1 ;
		i += 1
	i = 1
	while ( count < n ) :
		if ( ( i in mp ) and mp [ i ] > p_count ) :
			print ( i , end = ' ' ) ;
			if ( count < n - 1 ) :
				print ( " , ▁ " , end = ' ' ) ;
			p_count = mp [ i ] ;
			count += 1
		i += 1
if __name__ == ' _ _ main _ _ ' :
	n = 20 ;
	Highly_Totient ( n ) ;