Home >Backend Development >PHP Tutorial >PHP水仙花问题解法之一

PHP水仙花问题解法之一

WBOY
WBOYOriginal
2016-06-20 12:44:58958browse

<?php for($i=100;$i<=999;$i++){    $node=(string)$i;    $a = (int)$node[0]*(int)$node[0]*(int)$node[0];    $b = (int)$node[1]*(int)$node[1]*(int)$node[1];    $c = (int)$node[2]*(int)$node[2]*(int)$node[2];    if($a+$b+$c==$i){        echo $a."+".$b."+".$c."=".$i."<br/>";    }}?>

问题描述:100到999之间的任意一个数字abc=a的3次方+b的3次方+c的3次方

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