
Func: Integer m as a parameter then return the sum


Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 17, 2014, 12:32 PM
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);
}
}