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

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

function " /> 国产精品三级电影,国产精品欧美大片,国产主播一区二区

色尼玛亚洲综合影院,亚洲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 求質素(素數) 的實現代碼,轉載需保留來源!

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

主站蜘蛛池模板: 饶平县| 绿春县| 浦东新区| 娄烦县| 勃利县| 科尔| 姜堰市| 高雄县| 四子王旗| 二连浩特市| 顺义区| 玛纳斯县| 峨山| 东阿县| 平罗县| 龙海市| 白水县| 五河县| 自贡市| 乌拉特后旗| 乌审旗| 偃师市| 津市市| 安顺市| 宣威市| 宁南县| 腾冲县| 南雄市| 兴业县| 惠来县| 徐州市| 且末县| 嘉鱼县| 无锡市| 江川县| 彰化市| 成都市| 同江市| 常州市| 绥宁县| 莱阳市|