I am training in C# and we are in the Flow control looping and I am quite rusty in Math. I was given 2 problems and I am having doubts on the solutions.
∑ 5 = 1+ 2 + 3 + 4 + 5
Is this correct?
{ int input;
int som = 0;
Console.Write(“Enter a natural number: “);
input = Int32.Parse(Console.ReadLine());
for (int i = 1; i <= input ; i++)
{
som += i;
}
Console.WriteLine(“The sum is ” + som);
Console.ReadKey();
}