12345678910111213141516171819202122 |
- package kata
- /*
- Paperfold implements the general paperfold generation (OEIS A0014577) based
- on the algorithm given by Joerg Arndt, Apr 15 2010.
- See https://oeis.org/A014577
- */
- func PaperFold(ch chan<- int) {
- i := 1
- for {
- k := i
- h := k & -k
- k &= h << 1
- if k == 0 {
- ch <- 1
- } else {
- ch <- 0
- }
- i++
- }
- }
|