using System;
namespace Questions
{
class Program
{
public static int SumOfPowers(int n)
{
int sum = 0;
for (int i = 1; i <= n; i++)
sum += i * i;
return sum;
}
static void Main()
{
Console.Write("n = ");
int n = int.Parse(Console.ReadLine());
int sumOfPowers = SumOfPowers(n);
Console.WriteLine("\nOutput: " + sumOfPowers);
Console.ReadKey();
}
}
}
Comments
Leave a comment