Guest User

Untitled

a guest
Dec 13th, 2014
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.11 KB | None | 0 0
  1. $target = 479179/526680;
  2. $targetmax = $target + 0.000000001;
  3. $targetmin = $target - 0.000000001;
  4. $xsum = .0;
  5. $res = array();
  6.  
  7. function doone ($start,$depth){
  8.     $alpha = array (
  9.     1 => 'a', 2=>'b', 3=>'c', 4=>'d', 5=> 'e', 6=>'f',7=>'g', 8=>'h',
  10.     9 => 'i', 10=>'j', 11=>'k', 12=>'l', 13=>'m', 14=>'n',15=>'o', 16=>'p',
  11.     17=> 'q', 18=>'r', 19=>'s', 20=>'t', 21=>'u', 22=>'v', 23=>'w',24=>'x',
  12.     25=>'y',26=>'z');
  13.        
  14.     global $xsum, $res,$target,$targetmax,$targetmin;
  15.     foreach (range($start, 26) as $a) {
  16.         $m = 1/$a;
  17.             if ($xsum + $m > $targetmax){
  18.                 continue;
  19.             }
  20.             $xsum +=$m;
  21.             $res[]=$a;
  22.             if ($depth == 9){
  23.                 if ($targetmin < $xsum && $xsum < $targetmax){
  24.                     foreach ($res as $b) {
  25.                         echo $alpha[$b];
  26.                         }
  27.                         echo "\n";
  28.                     }
  29.                 } else {
  30.                     doone($a,$depth+1);
  31.                 }
  32.                 $xsum -= $m;
  33.                 array_pop ($res);
  34.         }
  35. }
  36. doone(2,1);
Advertisement
Add Comment
Please, Sign In to add comment