You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
package cses
|
|
|
|
import "fmt"
|
|
|
|
func WeirdAlgo(n int) string {
|
|
seq := []int{}
|
|
|
|
for n != 1 {
|
|
seq = append(seq, n)
|
|
|
|
if n%2 == 0 {
|
|
n /= 2
|
|
} else {
|
|
n = n*3 + 1
|
|
}
|
|
}
|
|
|
|
seq = append(seq, 1)
|
|
|
|
return fmt.Sprint(seq)
|
|
}
|