MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: fastest way to add up a billion numbers

  • To: mathgroup at smc.vnet.net
  • Subject: [mg73902] Re: fastest way to add up a billion numbers
  • From: "Graham Michalk" <gmichalk at optushome.com.au>
  • Date: Sat, 3 Mar 2007 00:52:19 -0500 (EST)
  • References: <es92b2$3oj$1@smc.vnet.net>

Raj,

On a modest Athlon 2800, Mathematica 5.2, 1GB RAM, WinXP Pro the following seems 
speedy!

In[1] = Timing[Sum[n, {n, 1, 10^9}]]

Out[1] = {0.062 Second, 500000000500000000}

Graham M

"Raj" <rajanikanth at gmail.com> wrote in message 
news:es92b2$3oj$1 at smc.vnet.net...
> hi!
>
> Could somebody tell me what would be the fastest way to add up a
> billion numbers(from 1 to 10^9 i.e the first billion numbers) in
> Mathematica?
>
> Ofcourse the answer is n(n+1)/2, but is there any other way in
> Mathematica other than the following one:
>
> Total@@Range[10^9]
>
> Thanks,
>
> Raj
>
> 




  • Prev by Date: Re: Sort with -Infinity fails
  • Next by Date: Re: The Mathematica equivalent of Cons (as in Lisp)?
  • Previous by thread: Re: fastest way to add up a billion numbers
  • Next by thread: Re: fastest way to add up a billion numbers