Ask Your Question
0

looping newline

asked 2012-09-22 20:57:59 +0100

anonymous user

Anonymous

updated 2012-09-22 23:03:48 +0100

kcrisman gravatar image

I am running Sage 5.1 under Windows 7 using the Virtual Box image.

When I enter a gp program with a newline it goes into a loop.

This works:

%gp
lucas(p) ={my(u,q); u=4; q=1<<p - 1;for(k=3,p, u = (sqr(u)-2) % q);u == 0;}
lucas(5)

But this does not:

%gp
lucas(p) ={
my(u,q); 
u=4;
q=1<<p - 1;
for(k=3,p, u = (sqr(u)-2) % q);
u == 0;
}
lucas(5)

Can you tell me what I need to do so that I can enter a program on multiple lines?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-09-23 18:14:20 +0100

benjaminfjones gravatar image

Well, escaping the newlines works, but's it's ugly:

%gp
lucas(p) ={\
my(u,q); \
u=4;\
q=1<<p - 1;\
for(k=3,p, u = (sqr(u)-2) % q);\
u == 0;\
}
lucas(5)

I think this might be a bug (or undocumented feature) in the GP interface.

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

Stats

Asked: 2012-09-22 20:57:59 +0100

Seen: 261 times

Last updated: Sep 23 '12