Re: sum the elements of a list
- To: mathgroup at smc.vnet.net
- Subject: [mg57500] Re: sum the elements of a list
- From: Jean-Marc Gulliet <jeanmarc.gulliet at 9online.fr>
- Date: Sun, 29 May 2005 21:00:20 -0400 (EDT)
- Organization: New York University
- References: <qp6me.4907$BR4.3152@news-server.bigpond.net.au>
- Reply-to: jmg336 at nyu.edu
- Sender: owner-wri-mathgroup at wolfram.com
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.