initial commit
This commit is contained in:
parent
6607be1a13
commit
f78ef0cd39
@ -1,2 +1,9 @@
|
||||
# php_pimebday
|
||||
|
||||
## requierments
|
||||
|
||||
- php > 7.4
|
||||
|
||||
## execute
|
||||
|
||||
execute the index.php from your web server
|
||||
|
31
index.php
Normal file
31
index.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
|
||||
function getNextPrimeBdays(int $age, int $countNextBdays,?int $ageLimit = null):array{
|
||||
if ($ageLimit === null){
|
||||
$ageLimit = 100;
|
||||
}
|
||||
$out = [];
|
||||
while($countNextBdays > 0) {
|
||||
for ($age = 32; $age <= $ageLimit; $age++) {
|
||||
$primenum = true;
|
||||
for($denominator = 2; $denominator <= $age/2; $denominator++) {
|
||||
if(((float)$age % (float)$denominator) == 0.0) {
|
||||
$primenum = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((bool)$primenum) {
|
||||
$out[] = $age;
|
||||
$countNextBdays--;
|
||||
if($countNextBdays == 0){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
echo json_encode(getNextPrimeBdays(32,10));
|
Loading…
Reference in New Issue
Block a user