PHP code to find the number of all daffodils less than 1000_PHP tutorial

WBOY
Release: 2016-07-21 15:22:06
Original
928 people have browsed it

The daffodil number is a number with n (>=3) digits, which is equal to the sum of the n powers of each number. For example, 153 is a daffodil number, 153=1³+5³+3³. Write a program and solve it The number of all daffodils less than 1000.

Copy code The code is as follows:

  for($ i=100;$i<1000;$i++){
$a=intval($i/100);
$b=intval($i/10)%10;
$c=$ i%10;
 if(pow($a,3)+pow($b,3)+pow($c,3)==$i){
 echo $i."t";
 }
 }
 ?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/324755.htmlTechArticleThe daffodil number is a number with n (=3) digits, which is equal to the nth power of each number The sum. For example, 153 is a daffodil number, 153=1+5+3. Write a program to solve for all daffodil numbers less than 1000. Complex...
source:php.cn
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!