Last active
March 23, 2017 17:02
-
-
Save Zoha131/8dd5577219d4a6f59d11442a9a48b68a to your computer and use it in GitHub Desktop.
Taking preparation for the take off contest.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
int t,i; | |
scanf("%d", &t); | |
for(i=0; i<t; i++) | |
{ | |
long double n,j,first_intry,last_entry,differ,sum, sum2=0; | |
unsigned long long int result; | |
scanf("%llf", &n); | |
first_intry = 1; | |
last_entry = pow(n,2)- pow(n-1,2); | |
differ = 2; | |
//calculating sum with the help of formula of series. | |
sum = (n/2)*(first_intry+last_entry); | |
result = (unsigned long long int)sum%((unsigned long int)pow(10,9)+7); | |
//printing sum and result to debug the programe. | |
printf("%llf\t%llu\n",sum,result); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment