Tiling with Dominoes | PHP program to find no . of ways to fill a 3 xn board with 2 x1 dominoes . ; Driver Code
< ? php function countWays ( $ n ) { $ A = array ( ) ; $ B = array ( ) ; $ A [ 0 ] = 1 ; $ A [ 1 ] = 0 ; $ B [ 0 ] = 0 ; $ B [ 1 ] = 1 ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) { $ A [ $ i ] = $ A [ $ i - 2 ] + 2 * $ B [ $ i - 1 ] ; $ B [ $ i ] = $ A [ $ i - 1 ] + $ B [ $ i - 2 ] ; } return $ A [ $ n ] ; } $ n = 8 ; echo countWays ( $ n ) ; ? >