human
Print all Perfect Numbers from an array whose sum of digits is also a Perfect Number | Function to check if a number is perfect number or not.
Stores sum of proper divisors.
If sum of digits is equal to N , then it 's a perfect number.
Otherwise , not a perfect number.
Function to find the sum of digits of a number.
Stores sum of digits.
Return sum of digits.
Function to count perfect numbers from an array whose sum of digits is also perfect.
Traverse the array.
If number is perfect.
Stores sum of digits of the number.
If that is also perfect number.
Print that number.
Driver Code.
Given array.
Size of the array.
Function call to count perfect numbers having sum of digits also perfect"
Solution in Python:
assistant
#Here is code to print all Perfect Numbers from an array whose sum of digits is also a Perfect Number and the other steps required.
 def isPerfect ( N ) :
	sumOfDivisors = 1 ;
	for i in range ( 2 , int ( N / 2 ) + 1 ) :
		if ( N % i == 0 ) :
			sumOfDivisors += i ;
	if ( sumOfDivisors == N ) :
		return True ;
	else :
		return False ;
def sumOfDigits ( N ) :
	sum = 0 ;
	while ( N != 0 ) :
		sum += ( N % 10 ) ;
		N = N // 10 ;
	return sum ;
def countPerfectNumbers ( arr , N ) :
	for i in range ( N ) :
		if ( isPerfect ( arr [ i ] ) ) :
			sum = sumOfDigits ( arr [ i ] ) ;
			if ( isPerfect ( sum ) ) :
				print ( arr [ i ] , end = " ▁ " ) ;
if __name__ == ' _ _ main _ _ ' :
	arr = [ 3 , 8 , 12 , 28 , 6 ] ;
	N = len ( arr ) ;
	countPerfectNumbers ( arr , N ) ;