eXorithm – Execute Algorithm: View / Run Algorithm reverse_factorial

Logo Beta

function reverse_factorial ($factorial

{

  $current = 1;

  while ($factorial > $current) {

    if ($factorial % $currentreturn -1;

    $factorial = $factorial$current

    $current++;

  }

  if ($factorial == $currentreturn $current

  else return -1;