- 注册
- 2002-10-12
- 消息
- 47,112
- 荣誉分数
- 2,376
- 声望点数
- 393
cola的pseudocode
-----------------
Question 1
input n
setup array of bool[n] with default values of all Ts
***
divisor = 2
while (divisor <= floor(root(n))) do
{
for i=(divisor+1) to n {
___if i mod divisor = 0 { bool=F }
}
temp=divisor+1
while (bool[temp]=F) do {temp++; divisor=temp+1}
}
***
print all the index of bool[n] such that bool[n]=T
--------------------
关于floor(root(n))的解释是
floor和ceiling,floor()舍尾,ceil() rounds up
root(n)求sqrt,JAVA中我们可以用Math.sqrt(x)
-----------------
Question 1
input n
setup array of bool[n] with default values of all Ts
***
divisor = 2
while (divisor <= floor(root(n))) do
{
for i=(divisor+1) to n {
___if i mod divisor = 0 { bool=F }
}
temp=divisor+1
while (bool[temp]=F) do {temp++; divisor=temp+1}
}
***
print all the index of bool[n] such that bool[n]=T
--------------------
关于floor(root(n))的解释是
floor和ceiling,floor()舍尾,ceil() rounds up
root(n)求sqrt,JAVA中我们可以用Math.sqrt(x)