First time here? Check out the FAQ!

Ask Your Question
1

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

asked 8 years ago

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!

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 8 years ago

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.

Preview: (hide)
link

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: 8 years ago

Seen: 170 times

Last updated: Aug 03 '16