PHP水仙花数
打印100-999之间的所有水仙花数
<?php $num = 100; while($num <= 999){ $gw = $num%10; $sw = ($num%100-$gw)/10; $bw = ($num-$num%100)/100; if($sw*$sw*$sw+$bw*$bw*$bw+$gw*$gw*$gw == $num){ echo $num; echo "<br/>"; } $num++; } ?>
For(初始条件;结束条件;步长){
如果条件结束为true,接着循环
}
浙公网安备 33010602011771号