Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: faster summation of primes

Tags:

haskell

primes

Disclaimer: I'm working on Euler Problem 9.

I'm adding up some pretty large numbers, all the primes from 1 to 2 000 000.

Summing those primes takes forever. I'm using the haskell built in function 'sum'.

as in:

sum listOfPrimes

Are there any other faster options?

--My prime generator was the slow link in my code.

like image 550
cbrulak Avatar asked Nov 27 '22 04:11

cbrulak


1 Answers

It sounds like your problem is not summing the numbers, but generating them. What is your implementation of listOfPrimes?

This paper may be of interest: http://lambda-the-ultimate.org/node/3127

like image 100
Edward Z. Yang Avatar answered Dec 05 '22 04:12

Edward Z. Yang