Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 5213
def simple_erato(n):#Fill in the blanks S=[] # S is a placeholder for primes <=k that will be removed L=[j]for j in range(0,n+1)# list of numbers <=n with L[0]=2; L will be changing k=2*n+1 # Fact:for any composite number less or equal n there is a prime factor <=k while L[0]<=k: S.append([2,n+1]) #Save the current prime in this list remove_multiple(2,L) return S+L simple_erato(50)
Error in lines 1-8 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags), namespace, locals) File "<string>", line 3 L=[j]for j in range(Integer(0),n+Integer(1))# list of numbers <=n with L[0]=2; L will be changing ^ SyntaxError: invalid syntax
def remove_multiple(m,L): for c in L: if (c % m)==0: L.remove(c) return L [L for L in range(2,51)] remove_multiple(c,)
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50]
Error in lines 7-7 Traceback (most recent call last): File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute flags=compile_flags), namespace, locals) File "", line 1, in <module> NameError: name 'c' is not defined