且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

[家庭作业]如何检查数字是否为素数

更新时间:2022-02-03 07:32:58

您的程序中已有for循环和函数调用。你在问什么?你想循环遍历2到10000之间的所有数字,但你已经这样做了。当它最终达到10000时,你希望它从10000循环回到2,这可以通过检查当前值是否>> 10000并且是否指定值2来重新开始来轻松完成。


如果您需要其他答案,您将不得不更详细地描述您的问题。
You have a for loop and a function call already in your program. What are you asking about? You want to loop through all the numbers between 2 and 10000, but you already do that. You want it to loop back from 10000 to 2 when it finally reaches 10000, that can be easily done by checking if the current value is >= 10000 and if it is assigning a value of 2 to start all over again.

If you need other answers you are going to have to describe your question in more detail.


展开 | 选择 | Wrap | 行号



您的程序中已有for循环和函数调用。你在问什么?你想循环遍历2到10000之间的所有数字,但你已经这样做了。当它最终达到10000时,你希望它从10000循环回到2,这可以通过检查当前值是否>> 10000并且是否指定值2来重新开始来轻松完成。


如果您需要其他答案,您将不得不更详细地描述您的问题。
You have a for loop and a function call already in your program. What are you asking about? You want to loop through all the numbers between 2 and 10000, but you already do that. You want it to loop back from 10000 to 2 when it finally reaches 10000, that can be easily done by checking if the current value is >= 10000 and if it is assigning a value of 2 to start all over again.

If you need other answers you are going to have to describe your question in more detail.



对不起,让我试着让它更清楚。我想在main中创建一个循环,循环从2到10000.循环将通过一个函数isPrime。 isPrime将检查一个数字是否为素数,如果是,则返回1,如果不是则返回0.

Sorry, let me try to make it more clear. I want to make a loop that is in main that loops from 2 to 10000. The loop will go through one function "isPrime". isPrime will check to see if a number is a prime or not and will return 1 if it is and if not return 0.