Fibonomial coefficient and Fibonomial triangle | PHP Program to print Fibonomial Triangle of height n . ; Function to produce Fibonacci Series . ; 0 th and 1 st number of the series are 0 and 1 ; Add the previous 2 numbers in the series and store it ; Function to produce fibonomial coefficient ; Function to print Fibonomial Triangle . ; Finding the fibonacci series . ; to store triangle value . ; initialising the 0 th element of each row and diagonal element equal to 0. ; for each row . ; for each column . ; finding each element using recurrence relation . ; printing the Fibonomial Triangle . ; Driven Program
< ? php $ N = 6 ; function fib ( & $ f , $ n ) { $ f [ 0 ] = 0 ; $ f [ 1 ] = 1 ; for ( $ i = 2 ; $ i <= $ n ; $ i ++ ) $ f [ $ i ] = $ f [ $ i - 1 ] + $ f [ $ i - 2 ] ; } function fibcoef ( $ fc , $ f , $ n ) { for ( $ i = 0 ; $ i <= $ n ; $ i ++ ) $ fc [ $ i ] [ 0 ] = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { for ( $ j = 1 ; $ j <= $ i ; $ j ++ ) { $ k = $ j ; while ( $ k -- ) $ fc [ $ i ] [ $ j ] *= $ f [ $ k ] ; $ k = 1 ; while ( ( $ j + 1 ) != $ k ) $ fc [ $ i ] [ $ j ] /= $ f [ $ k ++ ] ; } } } function printFibonomialTriangle ( $ n ) { global $ N ; $ f = array_fill ( 0 , $ N + 1 , 0 ) ; fib ( $ f , $ n ) ; $ dp = array_fill ( 0 , $ N + 1 , array_fill ( 0 , $ N + 1 , 0 ) ) ; for ( $ i = 0 ; $ i <= $ n ; $ i ++ ) $ dp [ $ i ] [ 0 ] = $ dp [ $ i ] [ $ i ] = 1 ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { for ( $ j = 1 ; $ j < $ i ; $ j ++ ) $ dp [ $ i ] [ $ j ] = $ f [ $ i - $ j + 1 ] * $ dp [ $ i - 1 ] [ $ j - 1 ] + $ f [ $ j - 1 ] * $ dp [ $ i - 1 ] [ $ j ] ; } for ( $ i = 0 ; $ i <= $ n ; $ i ++ ) { for ( $ j = 0 ; $ j <= $ i ; $ j ++ ) echo $ dp [ $ i ] [ $ j ] . " ▁ " ; echo " STRNEWLINE " ; } } $ n = 6 ; printFibonomialTriangle ( $ n ) ; ? >