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