You will need to store each value of number2 in a container as it's generated. When all the values of number2 have been generated then sort the container from high to low. Then use a loop using a counter (you could use second to do that) that ranges from 1 to less than or equal to number to print all the values of number2 stored in the container 5 values per line. If the loop counter % 5 equals zero then start a new line. If number % 5 is not equal to zero then the last line won't have 5 values in it.
As a learning experience when you have completed the task change the loop counter in the print out loop to range from 0 to less than number to see what difference it makes and try to explain why there is a difference in the appearance of the print out.