用一个函数获取质数的纳闷

WBOY
Release: 2016-06-13 12:36:40
Original
864 people have browsed it

用一个函数获取质数的疑惑

<br />
// 获取100―200之间的素数<br />
function main()<br />
{<br />
	for($i=100; $i<201; $i++){<br />
		$b = false;<br />
		for($j=2; $j<$i-1; $j++){<br />
			$k = $i % $j;<br />
			if($k == 0){<br />
				$b = true;<br />
				//break;<br />
			}<br />
		}<br />
		if(!$b){<br />
			echo $i ."<br>";<br />
		}<br />
	}<br />
}<br />
<br />
// 我的疑虑在break那个地方,测试最后的结果,有没有break,都是一样的结果。<br />
// 但如果要用程序来解释数学定义,就得加上break对吧?<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!