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

PHP水仙花问题解法之一

WBOY
Release: 2016-06-20 12:44:58
Original
979 people have browsed it

<?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/>";    }}?>
Copy after login

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

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