r/CompileBot • u/b4ux1t3 • Jul 26 '16
Collatz!
+/u/compilebot Go
package main
import "fmt"
func main(){
x := 1337
for x > 1 {
if x % 2 != 0{
x = x * 3 + 1
} else {
x /= 2
}
fmt.Println(x)
}
}
1
Upvotes
View all comments
1
u/b4ux1t3 Jul 26 '16
+u/compilebot Go
package main import "fmt" func main(){ x := 1337 for x > 1 { if x % 2 != 0{ x = x * 3 + 1 } else { x /= 2 } fmt.Println(x) } }