MathGroup Archive 2005

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

Search the Archive

Re: sum the elements of a list


morris wrote:
> After I do Divisors[28], I wish to add the elements of the list. How is this 
> possible?
> 
> Thanks
> Morris 
> 
> 
Hi Morris,

To do that, you must replace the head "List" of the list of divisors of 
28 returned by the command Divisors[28] by the head "Plus" (or "Times" 
if you wanted the product of the divisors for example).

In[1]:= Divisors[28]

Out[1]= {1,2,4,7,14,28}

In[2]:= Plus@@%

Out[2]= 56

In[3]:= Plus@@Divisors[28]

Out[3]= 56

In[4]:= Apply[Plus,Divisors[28]]

Out[4]= 56

Best regards,
/J.M.


  • Prev by Date: Mathematica TeX save in standard LaTeX style
  • Next by Date: Re: global fit
  • Previous by thread: Mathematica TeX save in standard LaTeX style
  • Next by thread: Re: sum the elements of a list