Maximum number of distinct positive integers that can be used to represent N | C ++ implementation of the approach ; Function to return the required count ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int count ( int n ) { return int ( ( -1 + sqrt ( 1 + 8 * n ) ) / 2 ) ; } int main ( ) { int n = 10 ; cout << count ( n ) ; return 0 ; }