For calculating the upper bound of the sequence .
global K NEW_LINE global N NEW_LINE global v NEW_LINE v = [ ] NEW_LINE while ( x > 0 ) : NEW_LINE INDENT v . append ( x % 10 ) NEW_LINE x //= 10 NEW_LINE DEDENT v = v [ : : - 1 ] NEW_LINE N = len ( v ) NEW_LINE def fun ( pos , sum , st , check , f ) : NEW_LINE global N NEW_LINE global v NEW_LINE if ( pos == N ) : NEW_LINE