For par condicio I have to show you the same problem solution but in my favorite language, Clojure.
Once again, it seems to me the coolest-freaking-awesome functional language in the world:
(defn div-1-20? [x] (defn aux [x acc] (cond (= x 0) false (= 0 acc) true (= 0 (mod x acc)) (aux x (dec acc)) :else false)) (aux x 20)) (first (filter div-1-20? (range)))
Even this solution runs in constant space, due to the range that generates a lazy sequence.
I love Clojure ❤
Bye!
Alfredo
References: