#NEWLINE# @ staticmethod #NEWLINE# @ recurrence_memo ( [ S . One , _sym ] ) #NEWLINE# def _bell_poly( n , prev ) : #NEWLINE# #INDENT# s = 1 #NEWLINE# a = 1 #NEWLINE# for k in range ( 2 , ( n + 1 ) ) : #NEWLINE# #INDENT# a = ( ( a * ( ( n - k ) + 1 ) ) // ( k - 1 ) ) #NEWLINE# s += ( a * prev [ ( k - 1 ) ] ) #NEWLINE# #UNINDENT# return expand_mul ( ( _sym * s ) )