 swizec.com

#### Senior Mindset Book

Get promoted, earn a bigger salary, work for top companies

# Project euler is a fun way to become a better geek

Yesterday I was a bit bored at the Theoretical Basis Of Computer Science class and the obvious solution was to try doing a bit of coding on an algorithm I'm trying to develop that aims to learn the proper syllabification for a language by reading it. Because I'm all sorts of cool I want to develop this thing in Clojure.

Naturally, the moment I started my severe lack of proficiency in clojure started showing through and I found myself spending more time online than coding. Somehow I ended up on stackoverflow where some guy suggested to another guy they go through the Project Euler problem set to get better at Clojure.

And so I did just that.

Have only managed to solve the first three problems so far, but by god this crap is fun. Maybe I'm just being way too dorky, but it's #WINNING!

Me being me, I've decided to motivate myself to solving these by posting a solution on this blog every time I solve a problem.

Here are the first three, probably less than elegant, but they're mine and I love them!

```;If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.;Find the sum of all the multiples of 3 or 5 below 1000..css-13aqjzy{display:inline-block;}
(defn nums [max n]  (loop [cnt (+ n n) acc [n]]    (if (>= cnt max) acc    (recur (+ cnt n) (concat acc [cnt])))))
(defn answer [max]  (println (reduce + (set (concat (nums max 3) (nums max 5))))))
```;Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:;1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...;By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.
(defn term [p-2 p-1]  (+ p-2 p-1))
(defn fib [max p-2 p-1 acc]  (if (>= p-1 max) acc      (fib max p-1 (term p-2 p-1) (concat acc [p-1]))))
(defn fibonacci [max p-2 p-1]  (fib max p-2 p-1 ))
(defn bla [a]  (if (even? a) a 0))
(defn answer [max]  (reduce + (map #(if (even? %1) %1 0) (fibonacci max 1 2))))
```; The prime factors of 13195 are 5, 7, 13 and 29.; What is the largest prime factor of the number 600851475143 ? 