Дано натуральное n. Вычислить значение суммы.(с помощью циклов FOR, WHILE) C#
язык c#
Приложения:

restIess:
язык программирования?
Ответы на вопрос
Ответил settom
1
Ответ:
using System;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter N = ");
int n = int.Parse(Console.ReadLine());
double Result = 1;
int i;
for (i = 0; i < n; i++) Result *= 1.0 + 1.0 / Math.Pow((double)(i+1), 2);
Console.WriteLine("For cycle result = " + Result.ToString());
i = 0;
Result = 1;
while (i < n) {
Result *= 1.0 + 1.0 / Math.Pow((double)(i+1), 2);
i++;
}
Console.WriteLine("While cycle result = " + Result.ToString());
Console.ReadLine();
}
}
}
Result *= 1.0 + 1.0 / Math.Pow((double)(i+1), 2.0);
using System;
namespace ConsoleApp
{
class cycle
{
static void Main()
{
Console.Write("Напишите значение переменной n: ");
int n = int.Parse(Console.ReadLine());
double Result = 1;
int i;
for (i = 1; i <= n; i++) Result *= 1.0 + 1.0 / Math.Pow(i, 2.0);
Console.WriteLine("Результат цикла for: {0}", Result);
i = 1;
Result = 1;
while (i <= n)
{
Result *= 1.0 + 1.0 / Math.Pow((double)i, 2.0);
i++;
}
Console.WriteLine("Результат цикла while: {0}", Result);
}
}
}
Новые вопросы
Математика,
2 года назад
Биология,
2 года назад
Биология,
7 лет назад
Математика,
8 лет назад
Математика,
8 лет назад