Skip to content

Instantly share code, notes, and snippets.

@MickhailP
Created January 10, 2023 17:35
Show Gist options
  • Save MickhailP/cc58cc49f575a316551fea2cca6d5585 to your computer and use it in GitHub Desktop.
Save MickhailP/cc58cc49f575a316551fea2cca6d5585 to your computer and use it in GitHub Desktop.
AlgorithmsRecursiveSum
func recursiveSum(_ nums: [Int]) -> Int {
if nums.count == 0 {
return 0
} else {
return nums[0] + recursiveSum(Array(nums.dropFirst()))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment