used to avoid duplicates in result
arr = [ ] ; for ( let i = 0 ; i <= Math . min ( x , y ) ; i ++ ) { let pq = [ i , Math . min ( x , y ) - i ] ; arr . push ( pq ) ; } for ( let [ key , value ] of arr . entries ( ) ) { document . write ( value [ 0 ] + " " + value [ 1 ] + " " ) } }