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

Posted 10 years ago
2857 Views
|
2 Replies
|
0 Total Likes
|
 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.
2 Replies
Sort By:
Posted 10 years ago
 Yeah, that's what I wanted, thanks.
Posted 10 years ago
 Are you saying you just want to sort all the numbers generated? as inTable[(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?