Skip to content

Instantly share code, notes, and snippets.

@ytkhs
Created May 9, 2015 17:07
Show Gist options
  • Save ytkhs/be51813943ab805375c0 to your computer and use it in GitHub Desktop.
Save ytkhs/be51813943ab805375c0 to your computer and use it in GitHub Desktop.
コラッツの問題 written in Go
package main
import "fmt"
func Collatz(i int) {
fmt.Println(i)
if i <= 1 {
return
}
if x := (i % 2); x == 1 {
Collatz(3*i + 1)
} else {
Collatz(i / 2)
}
}
func main() {
Collatz(127)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment