Bell Numbers ( Number of ways to Partition a Set ) | function that returns n 'th bell number ; Explicitly fill for j = 0 ; Fill for remaining values of j ; Driver Code
< ? php function bellNumber ( $ n ) { $ bell [ 0 ] [ 0 ] = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { $ bell [ $ i ] [ 0 ] = $ bell [ $ i - 1 ] [ $ i - 1 ] ; for ( $ j = 1 ; $ j <= $ i ; $ j ++ ) $ bell [ $ i ] [ $ j ] = $ bell [ $ i - 1 ] [ $ j - 1 ] + $ bell [ $ i ] [ $ j - 1 ] ; } return $ bell [ $ n ] [ 0 ] ; } for ( $ n = 0 ; $ n <= 5 ; $ n ++ ) echo ( " Bell ▁ Number ▁ " . $ n . " ▁ is ▁ " . bellNumber ( $ n ) . " STRNEWLINE " ) ; ? >