SHARE
TWEET

Strong number

MartinGeorgiev Jan 30th, 2019 (edited) 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $number = readline();
  3.  
  4. $sum = 0;
  5.  
  6. for ($i = 0; $i < strlen($number); $i++) {
  7.     $factorial = 1;
  8.     for ($j = 1; $j <= intval($number[$i]); $j++) {
  9.         $factorial *= $j;
  10.  
  11.     }
  12.     $sum += $factorial;
  13. }
  14.  
  15. if ($sum == intval($number)) {
  16.     echo "yes";
  17. } else {
  18.     echo "no";
  19. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top