Skip to content

Instantly share code, notes, and snippets.

@tylerlrhodes
Created May 8, 2017 00:34
Show Gist options
  • Save tylerlrhodes/150ec1d1341515e8c0ba291927614bdd to your computer and use it in GitHub Desktop.
Save tylerlrhodes/150ec1d1341515e8c0ba291927614bdd to your computer and use it in GitHub Desktop.
package main
import "fmt"
// Increment Natural number y
func Increment(y uint) uint {
if y == 0 {
return 1
}
if y%2 == 1 {
return (2 * Increment(y/2))
}
return y + 1
}
func main() {
fmt.Printf("%d\n", Increment(7))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment