For calculating the upper bound of the sequence .
v . Clear ( ) ; while ( x > 0 ) { v . Add ( x % 10 ) ; x /= 10 ; } v . Reverse ( ) ; N = v . Count ; } static int fun ( int pos , int sum , int st , int check , int f ) { if ( pos == N ) {