Sha256: fbe020bb3c3f77280118a63a81811bb215b1294ff4629cf1de1cef95612098da
Contents?: true
Size: 402 Bytes
Versions: 131
Compression:
Stored size: 402 Bytes
Contents
#lang racket (provide collatz) (define (collatz-length n [acc 0]) (if (= n 1) acc (collatz-length (if (even? n) (/ n 2) (add1 (* 3 n))) (add1 acc)))) (define (collatz n) (if (nand (exact-integer? n) (positive? n)) (error "number must be a positive integer") (collatz-length n)))
Version data entries
131 entries across 131 versions & 1 rubygems