Created
May 8, 2017 00:34
-
-
Save tylerlrhodes/150ec1d1341515e8c0ba291927614bdd to your computer and use it in GitHub Desktop.
This file contains 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 | |
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