A Dynamic Programming based solution to count number of ways to represent n as sum of four numbers
let dp = new Array ( 5001 ) ; for ( let i = 0 ; i < 5001 ; i ++ ) { dp [ i ] = new Array ( 5001 ) ; for ( let j = 0 ; j < 5001 ; j ++ ) { dp [ i ] [ j ] = new Array ( 5 ) ; } }