Example #1
0
function factorize(&$target, &$primes, &$factor)
{
    $multiplier = 2;
    $factored = true;
    $sieve = range($primes[count($primes) - 1] + 1, $factor);
    for ($i = 0; $i < count($primes); $i++) {
        if ($target % $primes[$i] == 0) {
            $target = $target / $primes[$i];
            if (isPrime($target)) {
                result(6857, $target);
                die;
            }
        }
        if ($i == count($primes) - 1) {
            $factored = false;
            $factor *= $multiplier;
            $primes = reducer($factor, $sieve, $primes, $target);
            factorize($target, $primes, $factor);
        }
    }
}
    function reducer($filename)
    {
        global $json;
        $per = $_POST['width_per'];
        if (!file_exists($filename)) {
            return false;
        }
        $original = getimagesize($filename);
        if ($original['mime'] == "image/jpeg") {
            $srcImage = imagecreatefromjpeg($filename);
            $reX = imagesx($srcImage);
            $reY = imagesy($srcImage);
            $srcW = $reX * $per;
            $srcH = $reY * $per;
            $dstImage = imagecreatetruecolor($srcW, $srcH);
            if (imagecopyresampled($dstImage, $srcImage, 0, 0, 0, 0, $srcW, $srcH, $reX, $reY)) {
                $time = time();
                $dest_image = "../../data/corners/temp/" . $time . ".jpg";
                if (imagejpeg($dstImage, $dest_image, 90)) {
                    if (!file_exists($dest_image)) {
                        $json .= '{"' . $filename . '":"' . $dest_image . '"},';
                    }
                }
            }
        }
        echo $json;
    }
    foreach ($filenames as $filename) {
        reducer($filename);
    }
}
Example #3
0
 $row = db_fetch_array($query);
 $kred_linje_id = $row['kred_linje_id'];
 $x = 0;
 $query = db_select("select id, ordrenr from ordrer where konto_id={$konto_id} and status>2 and art !='DK' and art !='KK'", __FILE__ . " linje " . __LINE__);
 while ($row = db_fetch_array($query)) {
     $x++;
     $kred_ordre_id[$x] = $row['id'];
     $kred_ordrenr[$x] = $row['ordrenr'];
 }
 $id_antal = $x;
 $y = 0;
 for ($x = 1; $x <= $id_antal; $x++) {
     $query = db_select("select id, antal from ordrelinjer where ordre_id={$kred_ordre_id[$x]} and vare_id = {$vare_id} and antal > 0", __FILE__ . " linje " . __LINE__);
     while ($row = db_fetch_array($query)) {
         $y++;
         print "<tr><td onClick=\"javascript:window.open('ordre.php?id={$kred_ordre_id[$x]}','{$kred_ordrenr[$x]}','width=400,height=400,scrollbars=1,resizable=1,menubar=no,location=no');\";><a href> {$kred_ordrenr[$x]}</a></td><td></td><td><td align = right>" . reducer($row['antal']) . "</td>";
         #		 print "<td align = right><input type=text style=\"text-align:right\" size=3 name=valg_$x value=$valg[$x]></td></tr>\n";
         print "<td align = center><input type=radio name=valg_1 value={$y}";
         if ($kred_linje_id == $row[id]) {
             print " checked='checked'></td>";
         } else {
             print "></td>";
         }
         if ($serienr) {
             print "<td onClick=\"javascript:batch=window.open('serienummer.php?linje_id={$linje_id}&batch_kob_id={$batch_kob_id[$x]}','batch','left=60,top=60,width=400,height=400,scrollbars=yes,resizable=yes,menubar=no,location=no')\">";
             print "<input type=button value=\"Serienr.\" name=\"vis_snr{$x}\"></td>";
         }
         print "<input type=hidden name=kred_linje_id[{$y}] value={$row['id']}>";
         $batch_antal = $y;
         print "</tr>";
     }
Example #4
0
function writer($ReduceNum = 42)
{
    $returnstring = "";
    $string = $returnstring;
    $a = 2 * 0;
    $l = $a + 2 * 14;
    $op = -1;
    while ($l != 3) {
        // Buchstabenrad
        if ($l >= 26) {
            while ($l >= sqrt(4)) {
                $l--;
            }
            $letter = chr(($l + reducer($ReduceNum)) * 32 + $l);
        }
        $count = 0;
        for ($i = 1; $i < $l; $i++) {
            $letter++;
            $count++;
        }
        unset($count);
        //Zuweisung
        $i = 0;
        while (isset($letter[$i])) {
            $string .= $letter[$i];
            if (strlen($string) <= 10) {
                $i++;
            }
        }
        if (isbreak($i)) {
            unset($i);
        }
        //algorithmus
        if ($l % 2 != 0) {
            //->ungerade
            $a += 2;
            if ($a <= 3) {
                $l += 13;
            } else {
                $l++;
            }
        } else {
            //->gerade
            if ($a < 4) {
                $l += 12;
            } else {
                $l += (23 - 3 * 8) * $op;
            }
            $a += $op;
        }
    }
    //Kehrung
    $l = 0;
    while (isset($string[$l])) {
        $string[$l] = strtolower($string[$l]);
        $l++;
    }
    $l--;
    $string[$l] = strtoupper($string[$l]);
    while (isset($string[$l])) {
        $returnstring .= $string[$l];
        $l--;
    }
    // omg:
    return $returnstring;
}
Example #5
0
            $sieve[$i] = 1;
        }
    }
    return $sieve;
}
function reducer($num, $sieve, $primes, $target)
{
    $negSieve = sieve($num, $primes);
    $new = $primes;
    foreach ($negSieve as $key => $value) {
        if ($value == 0 && isPrime($key, $primes)) {
            if (!in_array($key, $primes)) {
                $new[] = $key;
                if (count($new) - 1 == $target) {
                    result(104743, $new[$target - 1]);
                    die;
                }
            }
        }
    }
    return $new;
}
$primes = array(2, 3, 5, 7, 11, 13);
$target = 10001;
$sieve = range($primes[count($primes) - 1] + 1, 50);
$factor = $multiplier = 20;
while (count($primes) < $target) {
    echo "processing with a factor of " . $factor . "\n";
    $primes = reducer($factor, $sieve, $primes, $target);
    $factor *= $multiplier;
}