Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function SumListRecursive(numbers As List(Of Integer)) As Integer
- ' Base case: if the list is empty, return 0
- If numbers.Count = 0 Then
- Return 0
- Else
- ' Recursive case: add the first element to the sum of the rest of the list
- Return numbers(0) + SumListRecursive(numbers.Skip(1).ToList())
- End If
- End Function
Advertisement
Add Comment
Please, Sign In to add comment