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

php实现水仙花

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-23 13:12:481944browse

<br />

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();

?>

Statement:
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