mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
15 lines
210 B
C#
15 lines
210 B
C#
|
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;
|
||
|
}
|
||
|
}
|