Ask Your Question

redbaron01's profile - activity

2022-04-23 21:45:58 +0200 received badge  Notable Question (source)
2022-04-23 21:45:58 +0200 received badge  Popular Question (source)
2016-07-18 00:45:18 +0200 received badge  Scholar (source)
2016-07-17 01:47:16 +0200 commented answer Composite Number Sum Error

This is brilliant - thank you! Would you recommend switching from RDF to RLF and defining the precision of the real field in a way similar to the below method:

composites = (i for i in NN if i>3 and not i.is_prime())
s = RLF(0); s
RealField(300)(s)
for i in xrange(0,5000): s += (-1)^i / composites.next()
print s
2016-07-17 01:44:06 +0200 received badge  Supporter (source)
2016-07-16 20:34:24 +0200 received badge  Nice Question (source)
2016-07-16 16:04:17 +0200 commented question Composite Number Sum Error

OEIS A269229. The sum of ((-1)^n) / x(n) where x(n) is the next composite (non-prime) number.

2016-07-16 15:45:00 +0200 received badge  Student (source)
2016-07-16 13:29:20 +0200 asked a question 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