Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<stdio.h>
- using namespace std;
- int main()
- {
- long long int a,b,sum1,sum2,temp;
- while(scanf("%lld %lld",&a,&b)!=EOF)
- {
- if(a<b)
- {
- temp = a-1;
- sum1 = (b*(b+1)/2);
- sum2 = (temp*(temp+1)/2);
- printf("Sum of %lld to %lld is -> %lld;\n",a,b,sum1-sum2);
- }
- else
- {
- temp = b-1;
- sum1 = (a*(a+1)/2);
- sum2 = (temp*(temp+1)/2);
- printf("Sum of %lld to %lld is -> %lld;\n",a,b,sum1-sum2);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement