Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function is_prime($n) {
- $s = 0;
- for ($i = 1; $i <= floor(sqrt($n))+1; $i++) {
- $s += floor($n/$i)-floor(($n-1)/$i);
- }
- if ($s == 1) { return true; }
- else { return false; }
- }
- $height = 768;
- $width = 1366;
- $top = $height/4;
- $left = $width/4;
- $move = 0;
- $trace = 1;
- $traceB = 1;
- $count = 0;
- $next = 0;
- //0 : move right
- //1 : move top
- //2 : move left
- //3 : move bottom
- $str = "";
- for ($i = 2; $i <= 100000; $i++) {
- if ($count == $trace && $next == 0) {
- $count = 0; $next = 1; $move++; $move = $move % 4;
- } elseif ($count == $trace && $next == 1) {
- $count = 0; $next = 0; $trace++; $move++; $move = $move % 4;
- }
- if ($count < $trace) {
- $count++;
- }
- if ($move == 0) { $left++; }
- elseif ($move == 1) { $top++; }
- elseif ($move == 2) { $left--; }
- elseif ($move == 3) { $top--; }
- if (is_prime($i)) { $str .= "<div style='position: absolute; left: ".(2*$left)."px; bottom: ".(2*$top)."px'>.".
- "</div>"; }
- $str.="</div>";
- if ($i % 1000 == 0) { print "$i\n"; }
- }
- file_put_contents(".html",$str);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement