时间:2021-07-01 10:21:17 帮助过:32人阅读
class Armstrong {
static function index(){
for ( $i = 100; $i < 100000; $i++ ) {
echo self::is_armstrong($i) ? $i . '
' : '';
}
}
static function is_armstrong($num){
$s = 0;
$k = strlen($num);
$d = str_split($num);
foreach ($d as $r) {
$s += bcpow($r, $k);
}
return $num == $s;
}
}
Armstrong::index();
?>