Count of decreasing pairs formed from numbers 1 to N | Java program to count decreasing pairs formed from numbers 1 to N ; Function to count the possible number of pairs ; if the number is even then the answer in ( N / 2 ) - 1 ; if the number is odd then the answer in N / 2 ; Driver code
import java . util . * ; class GFG { static void divParts ( int N ) { if ( N % 2 == 0 ) System . out . println ( ( N / 2 ) - 1 ) ; else System . out . println ( ( N / 2 ) ) ; } public static void main ( String [ ] args ) { int N = 8 ; divParts ( N ) ; } }