Created
September 18, 2018 15:09
-
-
Save billglover/7f135a79a11047ba2ef4a3306c067a7d to your computer and use it in GitHub Desktop.
Increment an integer 1000 times (with a function call)
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 main() { | |
n := inc(1000) | |
println(n) | |
} | |
func inc(n int) int { | |
for i := 0; i < 1000; i++ { | |
n = add(n) | |
} | |
return n | |
} | |
func add(n int) int { | |
return n + 1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment