Check if all the digits of the given number are same | C # program for the above approach ; Function to check if all the digits in the number N is the same or not ; Get the length of N ; Form the number M of the type K * 111. . . where K is the rightmost digit of N ; Check if the numbers are equal ; Otherwise ; Driver Code
using System ; class GFG { public static String checkSameDigits ( int N ) { int length = ( ( int ) Math . Log10 ( N ) ) + 1 ; int M = ( ( int ) Math . Pow ( 10 , length ) - 1 ) / ( 10 - 1 ) ; M *= N % 10 ; if ( M == N ) return " Yes " ; return " No " ; } public static void Main ( ) { int N = 222 ; Console . WriteLine ( checkSameDigits ( N ) ) ; } }