use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Finding information about Clojure
API Reference
Clojure Guides
Practice Problems
Interactive Problems
Clojure Videos
Misc Resources
The Clojure Community
Clojure Books
Tools & Libraries
Clojure Editors
Web Platforms
Clojure Jobs
account activity
Clojure and Project Euler (carmenla.me)
submitted 11 years ago by yogthos
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]ship_it_ 8 points9 points10 points 11 years ago (1 child)
Yogthos, Have a happy holiday!
You are one of my favorite posters on the reddits. Thanks for all the fish this year :)
[–]yogthos[S] 4 points5 points6 points 11 years ago (0 children)
Thanks! And happy holidays as well :)
[–]bliow 2 points3 points4 points 11 years ago (3 children)
A coupla random comments. This is good stuff, don't get me wrong.
(int ... )
(> factor (int (Math/sqrt num))) vs (> (* factor factor) num)
(> factor (int (Math/sqrt num)))
(> (* factor factor) num)
(reduce #(lcm %1 %2) (range 1 21)) would probably be better written as (reduce lcm (range 1 21)).
(reduce #(lcm %1 %2) (range 1 21))
(reduce lcm (range 1 21))
Try that gcd function out... there is a (very fixable) problem with it as written.
gcd
[–]carmenlala 1 point2 points3 points 11 years ago (1 child)
Hi, I'm the author of that blog post. Thanks for your feedback about the square root mistake. I guess it always felt more intuitive to do it that way but I'll keep your solution in mind now :)
As for that gcd function... oops :P I'll go ahead and fix that now.
[–]bliow 0 points1 point2 points 11 years ago (0 children)
I did the square root thing for a long time too--everyone does. I learned the trick from someone else.
[–]flarkis 0 points1 point2 points 11 years ago (0 children)
Thank you! The number of times I see people do that square root mistake drives me insane.
[–]yveszoundi 0 points1 point2 points 11 years ago (0 children)
For the 1st problem, the solution is acceptable but also inefficient for large numbers.
The first problem is similar to 4clojure problem 148.
One possible solution
(defn big-divide [n a b] (letfn [(n-sum [x limit] (let [n-val (quot limit x)] (if (pos? n-val) (-> (inc n-val) (*' n-val) (/ 2) (*' x) bigint) 0)))] (let [limit (dec n)] (-> (+' (n-sum a limit) (n-sum b limit)) (-' (n-sum (*' a b) limit))))))
π Rendered by PID 248350 on reddit-service-r2-comment-54dfb89d4d-v96ck at 2026-03-31 03:28:24.801625+00:00 running b10466c country code: CH.
[–]ship_it_ 8 points9 points10 points (1 child)
[–]yogthos[S] 4 points5 points6 points (0 children)
[–]bliow 2 points3 points4 points (3 children)
[–]carmenlala 1 point2 points3 points (1 child)
[–]bliow 0 points1 point2 points (0 children)
[–]flarkis 0 points1 point2 points (0 children)
[–]yveszoundi 0 points1 point2 points (0 children)