Last active
August 29, 2015 14:02
-
-
Save Lysander/a7390350cd18d5c54479 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; | |
| ;; Lösung in Clojure | |
| ;; | |
| (defn make-func [x] | |
| (partial #(= (mod %2 %1) (- %1 1)) x)) | |
| (defn make-funcs [] | |
| (cons | |
| #(zero? (mod % 7)) | |
| (map make-func (range 2 7)))) | |
| (filter (apply every-pred (make-funcs)) (range 1 1001)) | |
| ;; gibt (119 539 959) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Lösung zu dieser Aufgabe in Python | |
| # x % 2 = 1 | |
| # x % 3 = 2 | |
| # x % 4 = 3 | |
| # x % 5 = 4 | |
| # x % 6 = 6 | |
| # x % 7 = 0 | |
| # | |
| # mit 1 <= x < 1000 | |
| from functools import partial | |
| funcs = [partial((lambda n, x: x % n == n-1), n) for n in range(2, 7)] | |
| funcs.append(lambda x: x % 7 == 0) | |
| for i in range(1, 1001): | |
| if all(f(i) for f in funcs): | |
| print(i, end=" ") | |
| # gibt: | |
| # > 119 539 959 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment