Skip to content

Instantly share code, notes, and snippets.

@benjic
Created February 10, 2013 16:15
Show Gist options
  • Save benjic/4750077 to your computer and use it in GitHub Desktop.
Save benjic/4750077 to your computer and use it in GitHub Desktop.
A small function for summing the first n terms of the function 2 + 2n.
package main
func sumAn( n int) int {
sum := 0
for i := 0; i < n; i++ {
sum += 2 + (2 * i)
}
return sum
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment