Sum of the first N Pronic Numbers | C ++ implementation to find sum of first N terms ; Function to calculate the sum ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; int calculateSum ( int N ) { return N * ( N - 1 ) / 2 + N * ( N - 1 ) * ( 2 * N - 1 ) / 6 ; } int main ( ) { int N = 3 ; cout << calculateSum ( N ) ; return 0 ; }