Advertisement
Guest User

1

a guest
Aug 22nd, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include<iostream>
  2. #include<stdio.h>
  3. using namespace std;
  4. int main()
  5. {
  6. long long int a,b,sum1,sum2,temp;
  7. while(scanf("%lld %lld",&a,&b)!=EOF)
  8. {
  9. if(a<b)
  10. {
  11. temp = a-1;
  12. sum1 = (b*(b+1)/2);
  13. sum2 = (temp*(temp+1)/2);
  14. printf("Sum of %lld to %lld is -> %lld;\n",a,b,sum1-sum2);
  15.  
  16. }
  17. else
  18. {
  19. temp = b-1;
  20. sum1 = (a*(a+1)/2);
  21.  
  22. sum2 = (temp*(temp+1)/2);
  23. printf("Sum of %lld to %lld is -> %lld;\n",a,b,sum1-sum2);
  24.  
  25.  
  26. }
  27. }
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement