Ask Your Question
1

Create a set of numbers with a equatation and 2 diffrent variables

asked 2016-08-03 15:36:49 +0100

Soul gravatar image

I need to create a set of numbers which are defined by m in [0..41] and n in [100]. The new created set needs to contain all the numbers which fulfill that condition.

I tried to accomplish that with:

A=[n^2+n+m^2 for n in [1..100] and m in [0..41]]

But Sage takes the and as an bool value not as another condition. can you help me with that?

(First time programming and english is not my mother tongue. Please be pleasefull)

Thanks alot!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-08-03 16:09:29 +0100

vdelecroix gravatar image

Your Python syntax is indeed wrong. It should be

sage:  A=[n^2+n+m^2 for n in [1..100] for m in [0..41]]

The "and" keyword is reserved for the binary operation.

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

1 follower

Stats

Asked: 2016-08-03 15:36:49 +0100

Seen: 112 times

Last updated: Aug 03 '16