Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- Console.OutputEncoding = Encoding.UTF8;
- Console.WriteLine("Сума на първите n-члена рекурсивно: ");
- Console.WriteLine(RecurSum(n));
- }
- static private int RecurSum(int n)
- {
- if (n ==0)
- {
- return 0;
- }
- return RecurSum(n - 1) + n;
- }
- }
- }
Add Comment
Please, Sign In to add comment