PHP to achieve a number of daffodils

What php number daffodils?

It refers to a number of n bits daffodils (n≥3), on which digital bits of each n-th power sum is equal to itself. (For example: 1 ^ 3 ^ 3 + 3 + 5 ^ 3 = 153)
number a total of three daffodils 4: 153,370,371,407;
number four of a total of three daffodils: 1634,8208,9474 ;
five daffodils total number of 3: 54748,92727,93084;
number six, only one daffodils: 548 834;

PHP seek daffodils number of programs, there are a variety of writing:

. 1 ? < PHP
 2  header ( "Content-type: text / HTML; charset = UTF-. 8;"); // Set the page. 8-encoded as UTF
 . 3  
. 4  // The following code number 1000 within daffodils solved 
. 5  echo ' <p> daffodils number less than 1000: </ P> ' ;
 . 6  
. 7  for ( $ I = 100; $ I <1000; ++ $ I ) {
 . 8      $ Hundreds = Floor ( $ I / 100);     // decomposition of one hundred 
. 9      $ TENS = Floor ( $ I / 10) 10%;    // decomposition ten 
10      $ ones =floor($i % 10);        //分解出个位
11     if (bcpow($hundreds, '3') + bcpow($tens, '3') + bcpow($ones, '3') == $i)
12         echo $i . "<br/>";
13 }
14 ?>

Output:

1 Number daffodils less than 1000:
 2 153
 . 3 370
 . 4 371
 . 5 407

 

Link: https: //mp.weixin.qq.com/s/0WvTNiVYntQu6H0RQOx3vQ

Guess you like

Origin www.cnblogs.com/clubs/p/11531743.html