哈斯克尔:更快的总理总和 [英] Haskell: faster summation of primes

查看:123
本文介绍了哈斯克尔:更快的总理总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

免责声明:我正在研究欧拉问题9。



我加上了一些非常大的数字,所有素数从1到200 000。 / p>

总结这些素数需要永久。我正在使用函数'sum'构建的haskell。



如下:

  sum listOfPrimes 

code>

还有其他更快的选项吗?

- 我的主要生成器是我的代码中的慢速链接。

解决方案

听起来像你的问题不是总结数字,而是产生它们。什么是你的listOfPrimes的实现?



这篇文章可能是有趣的: http://lambda-the-ultimate.org/node/3127


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.

解决方案

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

这篇关于哈斯克尔:更快的总理总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆