MathGroup Archive 2005

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

Search the Archive

Re: sum the elements of a list


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