MathGroup Archive 2005

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

Search the Archive

Re: sum the elements of a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg57664] Re: sum the elements of a list
  • From: "Drago Ganic" <drago.ganic at in2.hr>
  • Date: Fri, 3 Jun 2005 05:34:08 -0400 (EDT)
  • References: <qp6me.4907$BR4.3152@news-server.bigpond.net.au> <d7dp5o$qbl$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Hi Morris,
you can also use Total[ Divisors[28] ] ---> 56.

Best regards,
Drago Ganic

"Jean-Marc Gulliet" <jeanmarc.gulliet at 9online.fr> wrote in message 
news:d7dp5o$qbl$1 at smc.vnet.net...
> 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: Re: Re: Related quastions. Question 2
  • Next by Date: Re: simple set operations
  • Previous by thread: Re: OS X Keybindings
  • Next by thread: Re: Constrained Optimization