text: Nontrivial undulant Numbers | C # implementation to check if N is a Nontrivial undulant number ; Function to check if a string is double string or not ; a and b should not be equal ; Condition to check if length is odd make length even ; First half of s ; Second half of s ; Double string if first and last half are equal ; Function to check if N is an Nontrivial undulant number ; Driver code
code: using System ; class GFG { static bool isDouble ( int num ) { String s = num . ToString ( ) ; int l = s . Length ; if ( s [ 0 ] == s [ 1 ] ) return false ; if ( l % 2 == 1 ) { s = s + s [ 1 ] ; l ++ ; } String s1 = s . Substring ( 0 , l / 2 ) ; String s2 = s . Substring ( l / 2 ) ; return s1 . Equals ( s2 ) ; } static bool isNontrivialUndulant ( int N ) { return N > 100 && isDouble ( N ) ; } public static void Main ( String [ ] args ) { int n = 121 ; if ( isNontrivialUndulant ( n ) ) { Console . WriteLine ( " Yes " ) ; } else { Console . WriteLine ( " No " ) ; } } }