Explanation:
Given a number ‘N’ we need to output the number of total candies required
Basically, every person is given total candies based on his position,
So we Require 1+2+3+…+N candies which sums up to (N*(N+1))/2 (Sum of first ‘N’ natural numbers)
So here We need to output: N(N+1)/2
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int ans=(n*(n+1))/2;
cout<<ans<<"\n";
}