Skip to content

Instantly share code, notes, and snippets.

@isisnaomi
Created January 21, 2020 18:32
Show Gist options
  • Save isisnaomi/e1ea40516cfe9f448226d4743aeeb2cb to your computer and use it in GitHub Desktop.
Save isisnaomi/e1ea40516cfe9f448226d4743aeeb2cb to your computer and use it in GitHub Desktop.
func simpleAddingGauss(_ number: Int) -> Int {
return (number * (1 + number)) / 2
}
func simpleAddingNaive(_ number: Int) -> Int {
var sum = 0
for i in 0...number {
sum = sum + i
}
return sum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment