Saturday, June 24, 2017

uva problem solution 913 - Joana and the Odd Numbers

problem link:

Discuss: In this you just you have to simply calculate (((n*(n+2)/2)*3)-6)

try yourself before see the code


#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,j,sum,last,odd;
    while(cin >>n)
    {
        odd=(((n*(n+2)/2)*3)-6);
        cout <<odd<<endl;
    }
    return 0;
}

No comments:

Post a Comment