diff --git a/e0010/euler0010.bash b/e0010/euler0010.bash index fd0f5f8..09594d5 100755 --- a/e0010/euler0010.bash +++ b/e0010/euler0010.bash @@ -1,10 +1,12 @@ -#!/usr/bin/bash +#!/bin/bash # I have yet to see this script coming to an end... -declare -i primeSum=0 +declare -i primeSum=2 +sequence=$(seq 3 2 2000000) -for num in {2..2000000}; do +for num in $sequence; do + echo $num [[ "$(factor $num | cut -d " " -f2)" != $num ]] || primeSum=$(( $primeSum + $num )) done echo "$primeSum" diff --git a/e0010/euler0010.jl b/e0010/euler0010.jl new file mode 100644 index 0000000..d2f0e7d --- /dev/null +++ b/e0010/euler0010.jl @@ -0,0 +1,13 @@ +#!/usr/bin/julia +import Primes +function sumprimes(n::Int) + #primnumbers = SharedArray{Int}(n) + primesum=2 + parasum = @parallel (+) for i in 3:2:n + Primes.isprime(i)*i + end + primesum+=parasum +end +sumprimes(10) +@time prime = sumprimes(2000000) +print(prime) diff --git a/e0015/euler0015.jl b/e0015/euler0015.jl new file mode 100644 index 0000000..93b3095 --- /dev/null +++ b/e0015/euler0015.jl @@ -0,0 +1,26 @@ + +function euler0015(n::Integer) + n=big(n) + Int(div(prod(n+1:2n,1),factorial(big(n)))) +end + +function euler0015_2(n::Integer) + factorial(2*big(n))/factorial(big(n))^2 +end + +function euler0015_3(n::Integer) + n=big(n) + prod(n+1:2n,1)//factorial(big(n)) +end + +euler0015(3) +@time result=euler0015(big(20)) +println(result) + +euler0015_2(3) +@time result=euler0015_2(big(20)) +println(Int(result)) + +euler0015_3(3) +@time result=euler0015_3(big(20)) +println(result)