Fibonomial coefficient and Fibonomial triangle | Javascript 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 prvar 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 . ; Driver code
var N = 6 ; function fib ( f , n ) { var i ; 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 ++ ) { var k = j ; while ( k > 0 ) { k -- ; fc [ i ] [ j ] *= f [ k ] ; } k = 1 ; while ( ( j + 1 ) != k ) fc [ i ] [ j ] /= f [ k ++ ] ; } } } function printFibonomialTriangle ( n ) { var f = Array ( N + 1 ) . fill ( 0 ) ; fib ( f , n ) ; var dp = Array ( N + 1 ) ; for ( var i = 0 ; i < N + 1 ; i ++ ) dp [ i ] = Array ( N + 1 ) . fill ( 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 ++ ) document . write ( dp [ i ] [ j ] + " " ) ; document . write ( " " ) ; } } var n = 6 ; printFibonomialTriangle ( n ) ;