For calculating the upper bound of the sequence .
v . clear ( ) ; while ( x > 0 ) { v . add ( x % 10 ) ; x /= 10 ; } Collections . reverse ( v ) ; N = v . size ( ) ; } static int fun ( int pos , int sum , int st , int check , int f ) { if ( pos == N ) {