Created
September 3, 2010 01:25
-
-
Save sleepynate/563256 to your computer and use it in GitHub Desktop.
This file contains 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
; | |
; Project Euler Problem 3 | |
; Solution by nathan dotz - nathan (period) dotz (at sign) gmail (period) com | |
; | |
; What is the largest prime factor of the number 600851475143 ? | |
; | |
; | |
(ns euler3) | |
(def bignum 600851475143) | |
(def divisor ;only numbers who haves | |
(filter #(zero? (rem bignum %)) ; remainder 0 when dividing bignum | |
(filter odd? (range 2 (/ (Math/sqrt bignum) 6 ) ) ) ; up to big/6 | |
) | |
) | |
(def prime_divs | |
(for [x divisors :when | |
(every? #(not (zero? (rem x %)) ) ; | |
(range 2 (Math/sqrt x)) ) ; | |
] x ) | |
) | |
(last prime_divs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment