/** * Beispiele aus * * - Algorithmen und Datenstrukturen für Dummies * - von Andreas Gogol-Döring und Thomas Letschert * - Verlag Wiley-VCH; Oktober 2019 * - Kapitel 1, Das sind Algorithmen * * @author A. Gogol-Döring, Th. Letschert */ import Foundation struct AuD_01_04_Collatz { static func Collatz(n: Int) { var n_ = n while (n_ > 1) { print(n_) if (n_ % 2 == 0) { n_ = n_ / 2 } else { n_ = 3 * n_ + 1 } } } static func run() { Collatz(n: 25) } }