daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Jan 20th, 2018 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. function factorialArray($arrayNombre)
  3. {
  4. $factorials = array();
  5.  
  6.     if (is_array($arrayNombre) && is_int($arrayNombre)) {
  7.         foreach ($arrayNombre as $numero) {
  8.             for ($i = $numero - 1; i > 1; $i--) {
  9.                 $numero = $numero * $i;
  10.             }
  11.             $factorials[] = $numero;
  12.         }
  13.  
  14.         foreach ($factorials as $factorials){
  15.             echo $factorials;
  16.         }
  17.     }else{
  18.         return false;
  19.     }
  20. }
  21.  
  22.  
  23. $nombres = array(15, 42, 12, 22, 77);
  24.  
  25. factorialArray($nombres);
RAW Paste Data
Top