chamsi09

Untitled

Nov 14th, 2024
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.37 KB | None | 0 0
  1.     Function SumListRecursive(numbers As List(Of Integer)) As Integer
  2.         ' Base case: if the list is empty, return 0
  3.         If numbers.Count = 0 Then
  4.             Return 0
  5.         Else
  6.             ' Recursive case: add the first element to the sum of the rest of the list
  7.             Return numbers(0) + SumListRecursive(numbers.Skip(1))
  8.         End If
  9.     End Function
Advertisement
Add Comment
Please, Sign In to add comment