Count pairs having distinct sum from a given range | Function to count pairs made up of elements from the range [ L , R ] having distinct sum ; Stores the least sum which can be formed by the pairs ; Stores the highest sum which can be formed by the pairs ; Stores the count of pairs having distinct sum ; Print the count of pairs ; Driver Code ; Function call to count the number of pairs having distinct sum in the range [ L , R ]
function countPairs ( L , R ) { let firstNum = 2 * L ; let lastNum = 2 * R ; let Cntpairs = lastNum - firstNum + 1 ; document . write ( Cntpairs + " " ) ; } let L = 2 , R = 3 ; countPairs ( L , R ) ;