Count distinct sum of pairs possible from a given range | Java program for the above approach ; Function to count distinct sum of pairs possible from the range [ L , R ] ; Return the count of distinct sum of pairs ; Driver Code
import java . io . * ; class GFG { static int distIntegers ( int L , int R ) { return 2 * R - 2 * L + 1 ; } public static void main ( String [ ] args ) { int L = 3 , R = 8 ; System . out . println ( distIntegers ( L , R ) ) ; } }