
Func: Integer m as a parameter then return the sum

1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 17, 2014, 7:32 AM EST
using System;
class Program
{
static void Main()
{
int m;
do
{
Console.Write("Enter a positive integer : ");
int.TryParse(Console.ReadLine(), out m);
}
while(m < 1);
double root4 = Math.Pow(100, 0.25);
double sum = 0.0;
for(int y = 1; y <= m; y++)
{
sum += 2.0 * y + root4;
}
Console.WriteLine("The sum to {0} terms is {1}", m, sum);
Console.ReadKey(true);
}
}