Compute 1 + 2 + … + 10.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
class Program
{
static void Main()
{
int n = 10;
Console.WriteLine(n * (n + 1) / 2);
}
}
Try solving on your own first, then reveal the official answer.
Gauss formula or loop.