Under construction

Still being built. Things may change

Sum of Consecutive Integers

Interview

Time limit0.25sMemory limit128 MB

Summary
Given two integers, print the sum of all integers in the closed range between them, handling either order.
Level

Easy2 of 10

Topics
Math, Implementation
Solved
No attempts yet

Problem

Given two integers A and B, compute the sum of every integer between them, including both endpoints. A may be greater than B; in that case, still sum every integer in the closed interval between the two values.

Input

The first line contains two integers A and B separated by a space.

  • -2,147,483,648 ≤ A, B ≤ 2,147,483,647

Output

Print the sum of every integer between A and B on the first line. The output value is guaranteed to be between -2,147,483,648 and 2,147,483,647, inclusive.

Examples1

  1. Example 1

    Input
    1 2
    
    Expected output
    3