Counting pairs when a person can form pair with at most one | PHP program for Number of ways in which participant can take part . ; Driver code
< ? php function numberOfWays ( $ x ) { $ dp [ 0 ] = 1 ; $ dp [ 1 ] = 1 ; for ( $ i = 2 ; $ i <= $ x ; $ i ++ ) $ dp [ $ i ] = $ dp [ $ i - 1 ] + ( $ i - 1 ) * $ dp [ $ i - 2 ] ; return $ dp [ $ x ] ; } $ x = 3 ; echo numberOfWays ( $ x ) ; ? >