Created
February 10, 2013 16:15
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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