Skip to content

Instantly share code, notes, and snippets.

@billglover
Created September 18, 2018 15:09
Show Gist options
  • Save billglover/7f135a79a11047ba2ef4a3306c067a7d to your computer and use it in GitHub Desktop.
Save billglover/7f135a79a11047ba2ef4a3306c067a7d to your computer and use it in GitHub Desktop.
Increment an integer 1000 times (with a function call)
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