Created
May 28, 2014 02:20
-
-
Save shockalotti/8ce4a10d40cc28b3d73e to your computer and use it in GitHub Desktop.
Go Golang - halve integer
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 | |
import "fmt" | |
func halfNumber(x uint) (uint, bool){ | |
if x % 2 == 0 { | |
return x/2, true | |
} else { | |
return x/2, false | |
} | |
} | |
func main() { | |
x := uint(7) | |
fmt.Println(halfNumber(x)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment