On 26 June 2014 04:21, kcrisman <
kcri...@gmail.com> wrote:
>
>
>> Is there a way to only add the odd integers of a sum in Sage?
>
>
> Do you mean something like this?
>
> sage: L = [1,2,3,4,5,6,7,8,9,10]
> sage: L[1::2]
> [2, 4, 6, 8, 10]
> sage: L[0::2]
> [1, 3, 5, 7, 9]
> sage: sum(L[1::2])
> 30
Or perhaps this?
sage: L = [1,2,3,4,5,6,7,8,9,10]
sage: sum(L)
55
sage: sum([x for x in L if x%2==1])
25
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
sage-support...@googlegroups.com.
> To post to this group, send email to
sage-s...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/sage-support.
> For more options, visit
https://groups.google.com/d/optout.