diff options
| author | Mistivia <i@mistivia.com> | 2025-04-24 02:46:39 +0800 |
|---|---|---|
| committer | Mistivia <i@mistivia.com> | 2025-04-24 02:46:39 +0800 |
| commit | 2a9e59907868d12a2a3ea387ec90074e26cc90c3 (patch) | |
| tree | 8bc367c09ab4e1967481fd97abf1e29a81f62b04 /7-kyu/a-rule-of-divisibility-by-7.rkt | |
init
Diffstat (limited to '7-kyu/a-rule-of-divisibility-by-7.rkt')
| -rw-r--r-- | 7-kyu/a-rule-of-divisibility-by-7.rkt | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/7-kyu/a-rule-of-divisibility-by-7.rkt b/7-kyu/a-rule-of-divisibility-by-7.rkt new file mode 100644 index 0000000..6859107 --- /dev/null +++ b/7-kyu/a-rule-of-divisibility-by-7.rkt @@ -0,0 +1,15 @@ +#lang racket + +;; https://www.codewars.com/kata/55e6f5e58f7817808e00002e + +(provide seven) + +(define (seven m) + (define (impl cur steps) + (define x (quotient cur 10)) + (define y (modulo cur 10)) + (define next (- x (* 2 y))) + (if (< cur 100) + (cons cur steps) + (impl next (+ 1 steps)))) + (impl m 0)) |
