Count of decreasing pairs formed from numbers 1 to N | C ++ 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
#include <bits/stdc++.h> NEW_LINE using namespace std ; int divParts ( int N ) { if ( N % 2 == 0 ) cout << ( N / 2 ) - 1 << endl ; else cout << N / 2 << endl ; } int main ( ) { int N = 8 ; divParts ( N ) ; return 0 ; }