This is another way (print the last number in the end, outside the loop):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#include <iostream>
int main()
{
int n ;
std::cin >> n ;
int sum = n ;
for( int i = 1 ; i < n ; ++i )
{
sum += i ;
std::cout << i << " + " ;
}
std::cout << n << " == " << sum << '\n'
<< n << " * " << n+1 << " / 2 == " << n * (n+1) / 2 << '\n' ;
}