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());
- int f = int.Parse(Console.ReadLine());
- Console.OutputEncoding = Encoding.UTF8;
- Console.WriteLine("Сума на на естествените числа в интервала [n,f] ");
- Console.WriteLine(RecurSum(n,f));
- }
- static private int RecurSum(int n,int f)
- {
- if (n == f)
- {
- return n;
- }
- return RecurSum(n,f - 1) + f;
- }
- }
- }
Add Comment
Please, Sign In to add comment