Hi,
I want to make a function for a sum that has two different options for
each term, depending on a condition. E.g.
F(m) = sum(n=1, 10, if( m*n0, m*n+2, m*n+8))
How do I put the else if m*n0 then m*n+8 into the Sage statement:
sum( m*n +2 for n in range(1,10) if m*n0 ) ?
Thank you
Kim
--
One option is:
sage: def F(m):
:return sum([(m*n+2 if m*n 0 else m*n+8) for n in range(1, 10)])
sage: F(2)
162
sage: F(-2)
-72
--Mike
--
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to