### Project Euler - Problem #7

**Description**

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10001st prime number?

**Solution (Improved)**

My original solution was slow, and the code a bit ugly. The new solution is more idiomatic and dynamic than the original.

let isPrime n =

let upperBound = int32(sqrt(float(n)))

let allNumbers = [2..upperBound]

let divisors = allNumbers |> List.filter (fun div -> n % div = 0 && n <> div)

if List.length divisors = 0 then

true

else

false

let rec recursePrimes num count max =

if count = max then

num-1

else

if isPrime num then

recursePrimes (num+1) (count+1) max

else

recursePrimes (num+1) (count) max

let UT_recursePrimes = recursePrimes 2 0 10001

**Solution (Original)**

open System

let primeFind find =

let x = (find /10) * (find /10)

let upperBound = Convert.ToInt32(System.Math.Sqrt(Convert.ToDouble(x)))

let al…

## Comments

## Post a Comment