<commit_before>; https://projecteuler.net/problem=3

(ns euler.003
  (:require [clojure.math.numeric-tower :as math]))

(defmulti prime?
  "Returns true if a number is divisible by only 1 and itself, false otherwise."
  (fn [n] (cond
            (> 2 n) :not
            (= 2 n) :is)))

(defmethod prime? :not [_] false)

(defmethod prime? :is [_] true)

(defmethod prime? :default [n]
  (empty? (filter #(zero? (mod n %))
                  (range 2 (+ 1 (math/sqrt n))))))

(defn primes-below [n]
  "Returns a lazy seq of all possible primes below n."
  (filter prime? (range (int (math/floor n)) 1 -1)))

(defn possible-prime-factors-of [n]
  "Returns a lazy seq of all possible prime factors of n in order of largest to smallest."
  (primes-below (math/floor (math/sqrt n))))

(defn biggest-prime-divisor-of-n [n]
  "Lazily retrieves the first prime divisor "
  (let [possible-primes (possible-prime-factors-of n)]
    (first (drop-while #(not (zero? (mod n %)))
                       possible-primes))))<commit_msg>Clean up with comments, semantic fix<commit_after>; https://projecteuler.net/problem=3

(ns euler.003
  (:require [clojure.math.numeric-tower :as math]))

(defmulti prime?
  "Returns true if a number is divisible by only 1 and itself, false otherwise."
  (fn [n] (cond
            (> 2 n) :not
            (= 2 n) :is)))

(defmethod prime? :not [_] false)

(defmethod prime? :is [_] true)

(defmethod prime? :default [n]
  (empty? (filter #(zero? (mod n %))
                  (range 2 (+ 1 (math/sqrt n))))))

(defn primes-below [n]
  "Returns a lazy seq of all possible primes less than n."
  ; Use `int` to cast and floor n, subtract 1 so it's exclusive of `n`
  (filter prime? (range (dec (int n)) 1 -1)))

(defn possible-prime-factors-of [n]
  "Returns a lazy seq of all possible prime factors of n in order of largest to smallest."
  ; Add 1 so `primes-below` results includes `sqrt(n)`
  (primes-below (inc (math/floor (math/sqrt n)))))

(defn biggest-prime-divisor-of-n [n]
  "Returns the first prime divisor of n, or `nil` if ."
  (let [possible-primes (possible-prime-factors-of n)]
    (first (drop-while #(not (zero? (mod n %)))
                       possible-primes))))
{'fraction_non_alphanumeric': 0.1494096276112625, 'fraction_numerical': 0.010899182561307902, 'mean_word_length': 3.0054545454545454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3795794', 'n_tokens_mistral': 792, 'n_tokens_neox': 741, 'n_words': 271}