Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace Recursion
- {
- class Program
- {
- static void Main(string[] args)
- {
- var numbers = Console.ReadLine().Split().Select(int.Parse).ToArray();
- var sum = Sum(numbers, 0);
- Console.WriteLine(sum);
- }
- static int Sum(int[] numbers, int index)
- {
- if (index == numbers.Length - 1)
- {
- return numbers[index];
- }
- return numbers[index] + Sum(numbers, index + 1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment