human
Length of longest subsequence in an Array having all elements as Nude Numbers | Function to check if the number is a Nude number.
Variable initialization.
Integer ' copy ' is converted to a string.
Total digits in the number.
Loop through all digits and check if every digit divides n or not.
flag is used to keep check.
Return true or false as per the condition.
Function to find the longest subsequence which contain all Nude numbers.
Find the length of longest Nude number subsequence.
Given array arr [ ].
Function call"
Solution in Python:
 ... Can you provide a code to length of longest subsequence in an Array having all elements as Nude Numbers and the other steps required?
assistant
#Here is code to length of longest subsequence in an Array having all elements as Nude Numbers and the other steps required.
 def isNudeNum ( n ) :
	flag = 0
	copy = n
	temp = str ( copy )
	length = len ( temp )
	for i in range ( length ) :
		num = ord ( temp [ i ] ) - ord ( '0' )
		if ( ( num == 0 ) or ( n % num != 0 ) ) :
			flag = 1
	if ( flag == 1 ) :
		return False
	else :
		return True
def longestNudeSubseq ( arr , n ) :
	answer = 0
	for i in range ( n ) :
		if ( isNudeNum ( arr [ i ] ) ) :
			answer += 1
	return answer
arr = [ 34 , 34 , 2 , 2 , 3 , 333 , 221 , 32 ]
n = len ( arr )
print ( longestNudeSubseq ( arr , n ) )