First of all, starting from 2, this is the first prime number. Put it in an array (here called array (sorted)) for later use.
Then look at 3, the square takes the integer part, that is, 1. Divide 3 by a prime number that is less than or equal to 1 and is in the array. If there is a prime number that is not divisible, put it in the array (remember to sort it, that is, after 2). Obviously, there is no prime number less than 1 in the array, so 3 is also a prime number. So far, two prime numbers have been found in the array.
Then look at 4, square it to get the integer part 2, divide it by the prime number less than or equal to 2 in the array, and find that it can be divisible by 2, which means that 4 is not a prime number.
Let's look at 5, square it and get the integer part of 2. Divide by a prime number less than or equal to 2 in the array, and find that it is not divisible, which means it is a prime number. Put it in the array, and now there are prime numbers in the array, which are 2, 3 and 5.
Also look at 6, square it and get the integer part of 2. Divided by the prime number less than or equal to 2 in the array, it is found that it can be divisible by 2, indicating that 4 is not a prime number.
then ...................
Finally, what you get in the array is the sorted prime numbers.
Here are two questions for you to think about.
1, why do you want to square the judged number, and it is enough to take the integer part?
2. Why is it enough to divide by prime numbers instead of non-prime numbers such as 4, 6 and 9?
If you can answer these two questions, it shows that you understand why you want to put the obtained prime numbers into the array, and why this algorithm is the most efficient algorithm to meet your requirements.
If you don't understand, you can ask me again if you have any questions.