Message Boards Message Boards

0
|
2995 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Trying to do a weird sort thing in Mathematica, not sure how

So here's something interesting:

The numbers which cannot be expressed as the sum of three squares are of this form: (4^x)*(7+8n), for x and n positive integers.

I'm trying to have Mathematica generate an ordered list of these numbers up to, say, a thousand (just as an example). I can get it to generate numbers like this:
Table[(4^x) (7 + 8 n), {x, 0, 2}, {n, 0, 5}]
The output is this:

{{7, 15, 23, 31, 39, 47}, {28, 60, 92, 124, 156, 188}, {112, 240, 368, 496, 624, 752}}

Which seems to be three lists of six things, which makes sense. The thing is if I use Sort to sort these, it sorts the individual lists, which are already sorted. How can I put these lists together and sort them (without doing it manually?)

Sorry if this is too basic to be asked here.
POSTED BY: max mathless
2 Replies
Are you saying you just want to sort all the numbers generated? as in
Table[(4^x) (7 + 8 n), {x, 0, 2}, {n, 0, 5}];
Sort[Flatten[%]]
(*{7, 15, 23, 28, 31, 39, 47, 60, 92, 112, 124, 156, 188, 240, 368, 496, 624, 752}*)
Or something else?
POSTED BY: Nasser M. Abbasi
Yeah, that's what I wanted, thanks. 
POSTED BY: max mathless
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract