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";
}
}
?>
http://www.bkjia.com/PHPjc/324755.htmlwww.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...
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