Advertisement
apexsquirt

collatzyboi.php

Jul 15th, 2020
1,255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.98 KB | None | 0 0
  1. <?php
  2. if (isset($_GET["base"]))
  3.     $const = intval($_GET["base"]);
  4. else $const = 2;
  5. if (isset($_GET["brightness"]))
  6.     $brightness = intval($_GET["brightness"]);
  7. else $brightness = 1500;
  8. ?>
  9. <title>col(n,<?=$const;?>)</title>
  10. <body bgcolor="black" style="color: white">
  11. <?php
  12. function col ($n, $b = 2) {
  13.     return ($n % $b == 0) * ($n/$b)
  14.          + ($n % $b >  0) * ($n+intval($n/$b)+1);
  15. }
  16. $maxi = 0;
  17. $array = [];
  18. for ($i = 1; $i < 10000; $i++) {
  19.     $m = $i;
  20.     while (!in_array($m,$array)) {
  21.         $array[count($array)] = $m;
  22.         $m = col($m,$const);
  23.     }
  24. }
  25. foreach ($array as $i => $e) {
  26.     print "<div style='position: absolute; left: ".(10+array_search(col($e,$const),$array)/10)
  27.                                        ."; bottom: ".(10+col($e,$const)/10).";
  28.     color: rgba(".($brightness/$e*255).",0,0,0.5)'>.</div>\n";
  29. }
  30. ?>
  31. <form method="get">
  32. Base : <input type="text" name="base" value="<?=$const;?>"><br>
  33. Brightness : <input type="text" name="brightness" value="<?=$brightness;?>"><br>
  34. <input type="submit">
  35. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement