C # code to count the frequency of 1 in numbers less than or equal to the given number .
using System ; class GFG { static int countDigitOne ( int n ) { int countr = 0 ; for ( int i = 1 ; i <= n ; i ++ ) { string str = i . ToString ( ) ; countr += str . Split ( "1" ) . Length - 1 ; } return countr ; }