算法,水仙花数 eqphp '; }}static function cube($num){ return $num * $num * $num;}static function is_narcissus($num){ $hundreds = floor($num / 100); //分解出百位 $tens = floor($num / 10 ) % 10; //分解出十位 $ones = floor($num % 10 ); //分解出个位 return (bool)(self::cube($hundreds)+self::cube($tens)+self::cube($ones) == $num);}}
