Skip to content

Instantly share code, notes, and snippets.

@Lysander
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save Lysander/a7390350cd18d5c54479 to your computer and use it in GitHub Desktop.

Select an option

Save Lysander/a7390350cd18d5c54479 to your computer and use it in GitHub Desktop.
;;
;; 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)
# 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