All pastes #566450 Raw Edit

Mine

public php v1 · immutable
·published 2007-06-14 13:24 UTC
rendered paste body
#!/usr/bin/php<?php$size = 1000;$target = str_repeat('9', 2500);$digits = range(0, $size - 1);$perms = array(1 => 1);for ($i = 2; $i < $size; $i++) {        $perms[$i] = bcmul($perms[$i - 1], $i);}$perms = array_reverse($perms);if (bccomp($target, bcmul($size, $perms[0])) == 1) {        die("Warning: target permutation exceeds total permutations!\n");}else {        print('Permutation:' . "\t" . (double) $target . "\n");        print('Set size:' . "\t" . $size . "\n\n");}$values = array();foreach ($perms as $n) {        $values[] = floor(bcdiv($target, $n));        $target = bcmod($target, $n);}foreach ($values as $i => $m) {        print($digits[$m] . ",");        unset($digits[$m]);        sort($digits);        if ($i%30 == 29) {                print("\n");        }}print("$digits[0]\n");?>