diff --git a/index.php b/index.php index 6128a39..c80cd67 100644 --- a/index.php +++ b/index.php @@ -2,15 +2,11 @@
- +" . implode(", ", $primeNumbers) . "
"; } } - function isPrime($i) { - if ($i <= 1) return false; - if ($i <= 3) return true; - if ($i % 2 == 0) return false; + function isPrime(int $n): bool { + if ($n <= 1) return false; + if ($n <= 3) return true; + if ($n % 2 === 0) return false; - for ($j = 3; $j * $j <= $i; $j += 2) { - if ($i % $j == 0) { - return false; - } + $limit = (int) floor(sqrt($n)); + for ($d = 3; $d <= $limit; $d += 2) { + if ($n % $d === 0) return false; } return true; @@ -64,12 +60,17 @@ = 0.5 ? 1 : 0; - $starsCount = (int) floor($ln); - $stars = $starsCount > 0 ? str_repeat('*', $starsCount) : '-'; + if ($full === 0 && $half === 0) { + $visual = '-'; + } else { + $visual = str_repeat('*', $full) . ($half ? '+' : ''); + } - echo sprintf("%3d: ln=%6s %s