Home > Backend Development > PHP Tutorial > php实现水仙花

php实现水仙花

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-23 13:12:48
Original
1947 people have browsed it

<br />
Copy after login

class Armstrong {

 static function index(){

  for ( $i = 100; $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();

?>

Related labels:
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