Ask Your Question
0

Table of primes

asked 2013-03-23 10:44:58 -0500

Luiz Roberto Meier gravatar image

Hello,

I'm trying to create a table (or matrix, what comes first) with the first rank is the primes_range from 2 to 29 and the first column with primes_range from 2 to 29 too.

Then, I want to add i[0] + j[0] = element 4 using the values above.

The reason for that is that I want to create a table of even elements based on Goldbach conjecture that says that an even is the sum of two equal (or different) primes:

4 = 2 + 2 6 = 3 + 3 8 = 3 + 5

The problem is that an even number can be written in several ways, example:

24 = 5 + 19 24 = 7 + 17 24 = 11 + 13 and so on..

The number 200 = 3 + 197 . So, my problem is to 'remember' in a for/loop the number 3. When I'm close to the even 200 the number variable that holds the first prime is far away from 3.

So, I think the solution maybe can be a combination or a value table or a matrix.

Thank you in advance.

P.S.: This is not a homework.

edit retag flag offensive close merge delete

Comments

1

What is the question?

fidbc gravatar imagefidbc ( 2013-03-23 12:11:32 -0500 )edit

I want to create a matrix of prime elements starting, say, from 2 up to 197 OR a matrix of elements starting from 2 up to 200 where the elements that are primes have another shape or color. If you don't understand I can DRAW it to you. Thank you.

Luiz Roberto Meier gravatar imageLuiz Roberto Meier ( 2013-03-25 03:03:52 -0500 )edit

It is more or less clear what you want to achieve. You just didn't state an explicit question. Is it about how to create a [matrix](http://www.sagemath.org/doc/reference/matrices/sage/matrix/constructor.html)? Is it about how to generate lists of [prime](http://combinat.sagemath.org/doc/reference/misc/sage/rings/arith.html#sage.rings.arith.primes) numbers? What do you mean by shape or color? I'm starting to think a python dict might suit your purposes better.

fidbc gravatar imagefidbc ( 2013-03-25 04:04:49 -0500 )edit

You can think about it as a group too. But, forget. I can learn it alone without your funny help.

Luiz Roberto Meier gravatar imageLuiz Roberto Meier ( 2013-03-26 18:09:09 -0500 )edit

There is no place for insult here. Moreover with somebody who tries to help and knows Sage much better than you ! As fidelbc said before : there is no question in your post and your aim is unclear.

vdelecroix gravatar imagevdelecroix ( 2013-03-29 02:30:01 -0500 )edit

1 answer

Sort by » oldest newest most voted
1

answered 2013-03-29 02:33:48 -0500

I am not sure what is your aim, but the function prime_range returns you a list of the prime integers below a given bound

sage: prime_range(20)
[2, 3, 5, 7, 11, 13, 17, 19]
sage: prime_range(50)
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]
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

2 followers

Stats

Asked: 2013-03-23 10:44:58 -0500

Seen: 183 times

Last updated: Mar 29 '13