Bell Numbers ( Number of ways to Partition a Set ) |  ; Explicitly fill for j = 0 ; Fill for remaining values of j ; Driver program
/ * Function to find n ' th Bell Number * / NEW_LINE def bellNumber ( n ) : NEW_LINE INDENT bell = [ [ 0 for i in range ( n + 1 ) ] for j in range ( n + 1 ) ] NEW_LINE bell [ 0 ] [ 0 ] = 1 NEW_LINE for i in range ( 1 , n + 1 ) : NEW_LINE INDENT bell [ i ] [ 0 ] = bell [ i - 1 ] [ i - 1 ] NEW_LINE for j in range ( 1 , i + 1 ) : NEW_LINE INDENT bell [ i ] [ j ] = bell [ i - 1 ] [ j - 1 ] + bell [ i ] [ j - 1 ] NEW_LINE DEDENT DEDENT return bell [ n ] [ 0 ] NEW_LINE DEDENT for n in range ( 6 ) : NEW_LINE INDENT print ( ' Bell ▁ Number ' , n , ' is ' , bellNumber ( n ) ) NEW_LINE DEDENT