Ask Your Question

What broke?

asked 2012-09-23 05:23:04 -0500

dazedANDconfused gravatar image

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

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?

edit retag flag offensive close merge delete


If you can edit the question title to something more informative, it might help other folks who run into the same problem down the road.

benjaminfjones gravatar imagebenjaminfjones ( 2012-09-23 11:10:44 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2012-09-23 06:45:03 -0500

Alex Kramer gravatar image

updated 2012-09-23 06:45:17 -0500

The problem (which is definitely a regression on our end), is stemming from FigureSize using a generator for a list.

For now, if you change the relevant portion to:

FigureSize =  slider([i +1 for i in xrange(20)], default = 9, label="figure size")

the code works as expected. I've opened a bug report here:

edit flag offensive delete link more


Thanks for your help!

dazedANDconfused gravatar imagedazedANDconfused ( 2012-09-23 09:11:14 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-09-23 05:23:04 -0500

Seen: 268 times

Last updated: Sep 23 '12