package main import "fmt" func main() { // Based on http://www.kaoriya.net/blog/2013/02/04/ var a, b, c int fmt.Scan(&a, &b) for b != 0 { c = (a & b) << 1 a ^= b b = c } fmt.Println(a) }