function __construct() { $this->time_start = 0; $this->time_end = 0; }

function timer() { $this->__construct(); }

function " /> 欧美一区二区三区免费观看,亚洲日本一区二区三区在线不卡,岛国av免费在线观看

色尼玛亚洲综合影院,亚洲3atv精品一区二区三区,麻豆freexxxx性91精品,欧美在线91

php 求質素(素數) 的實現代碼

復制代碼 代碼如下:
<?php
class timer
{
var $time_start;
var $time_end;

function __construct()
{
$this->time_start = 0;
$this->time_end = 0;
}

function timer()
{
$this->__construct();
}

function start()
{
list($usec,$sec) = explode(" ",microtime());
$this->time_start = (float)$usec + (float)$sec;
}

function stop()
{
list($usec,$sec) = explode(" ",microtime());
$this->time_end = (float)$usec + (float)$sec;
}

function show($output = false)
{
$total = $this->time_end - $this->time_start;
if ($output) {
echo $total," sec";
return true;
}
return $total." sec";
}

}
?>
<?php
echo 'check prime<br/>';
function IsPrime($i)
{
if($i<2)
{
return false;
}
//var $iterator;
for($iterator = 2 ; $iterator <= sqrt($i) ; $iterator++)
{
if($i % $iterator==0)
{
return false;
}
}
return true;
}

$sw=new timer();
$sw->start();
for($j=1;$j<100;$j++)
{
if(IsPrime($j))
{
echo 'true<br/>';
}
else
{
echo 'false<br/>';
}
}
$sw->stop();
$sw->show(true);

?>

php技術php 求質素(素數) 的實現代碼,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 潼关县| 高密市| 高碑店市| 钦州市| 苏尼特右旗| 三门峡市| 崇仁县| 赫章县| 柳江县| 抚宁县| 大埔县| 新泰市| 平罗县| 钦州市| 吴堡县| 灵璧县| 陇川县| 新泰市| 瓦房店市| 濮阳县| 临沧市| 安泽县| 朝阳县| 北辰区| 永济市| 体育| 腾冲县| 定西市| 海南省| 东明县| 阜新| 孟村| 张家港市| 米泉市| 太湖县| 辉县市| 韶关市| 攀枝花市| 汪清县| 盖州市| 图们市|