1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-09 11:09:07 +01:00
CodeWars/7kyu/beginner_series_iii/solution.cs

15 lines
210 B
C#
Raw Normal View History

using System;
public class Sum
{
public int GetSum(int a, int b)
{
if (a > b) {
var temp = a;
a = b;
b = temp;
}
return (a + b) * (Math.Abs(b - a) + 1) / 2;
}
}