Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Composite Number Sum Error

New to sage, although familiar with a few other coding langages. Trying to obtain a sum of alternating terms. Any idea on this one? Thanks in advance.

def a(n) : return [k for k in (1..n) if not is_prime(k)] from mpmath import * mp.dps = 15 mp.pretty = True nsum(lambda n: (1)/(a(n)), [1,5000], method='alternating')

Error Received:
TypeError: unable to coerce <type 'sage.libs.mpmath.ext_main.mpf'=""> to an integer

Composite Number Sum Error

New to sage, although familiar with a few other coding langages. Trying to obtain a sum of alternating terms. Any idea on this one? Thanks in advance.

def a(n) : return [k for k in (1..n) if not is_prime(k)]
from mpmath import *
mp.dps = 15
mp.pretty = True
nsum(lambda n:  (1)/(a(n)), [1,5000], method='alternating')

method='alternating')

Error Received:

TypeError: unable to coerce <type 'sage.libs.mpmath.ext_main.mpf'="">
'sage.libs.mpmath.ext_main.mpf'>
to an integer

integer