Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

What broke?

This code worked in Sage 4.8 and I show it working in the Sage Cell server back in July:

@interact 
def _GoldbachConj(Number = slider(4,600,2,4, label="Number"),FigureSize =  slider([1..21],default = 9, label="figure size"),Calculation = selector(['check one number','all numbers up to a number'],default = 'check one number', label = "Calculation choice")):
html('<h2 align=center>%s</h2>'%"Goldbach's Conjecture")
if (Calculation=='check one number'):  
    for i in range(2,Number/2+1):
        if is_prime(i) and is_prime(Number-i):
            print i, " + ", Number-i, " = ", Number
elif (Calculation=='all numbers up to a number'): 
    for i in range(4,Number+1,2):
        for j in range(2,i/2+1):
            if (is_prime(j) and is_prime(i-j)):
                print j, " + ", i-j, " = ", i

image description

This code no longer works for the current Sage Cell server, giving an error message for invalid syntax (line 2). What's broken and how do I fix it?