Вычислить выражение, используя рекурсию - C# (177738)
Формулировка задачи:
Добрый день, нужна помощь с заданием. Не совсем понимаю как его реализовать.
Решение задачи: «Вычислить выражение, используя рекурсию»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Recurs1
{
class Program
{
static double Rec_(int i, int N)
{
double result;
if (i == N)
return Math.Sqrt(N);
else return Math.Sqrt(i + Rec_(i + 1, N));
}
static double Rec (int N)
{
return Rec_(1, N);
}
static void Main(string[] args)
{
Console.WriteLine("Введите число");
int N = Convert.ToInt32(Console.ReadLine());
double x = N/Rec(N);
Console.WriteLine("F("+N+")=" + x);
Console.ReadKey();
}
}
}