Length of longest subsequence in an Array having all elements as Nude Numbers | C # program for the above approach ; Function to check if the number is a Nude number ; Variable initialization ; int ' 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 ; Driver Code ; Given array [ ] arr ; Function call
using System ; class GFG { static bool isNudeNum ( int n ) { int copy , length , flag = 0 ; copy = n ; String temp ; temp = String . Join ( " " , copy ) ; length = temp . Length ; for ( int i = 0 ; i < length ; i ++ ) { int num = temp [ i ] - '0' ; if ( num == 0 n % num != 0 ) { flag = 1 ; } } if ( flag == 1 ) return false ; else return true ; } static int longestNudeSubseq ( int [ ] arr , int n ) { int answer = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( isNudeNum ( arr [ i ] ) ) answer ++ ; } return answer ; } public static void Main ( String [ ] args ) { int [ ] arr = { 34 , 34 , 2 , 2 , 3 , 333 , 221 , 32 } ; int n = arr . Length ; Console . Write ( longestNudeSubseq ( arr , n ) + " STRNEWLINE " ) ; } }