Skip to content

Instantly share code, notes, and snippets.

@savasdersimcelik
Created November 22, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savasdersimcelik/b35094b4d87d7fcfc8bd4f31bf278edd to your computer and use it in GitHub Desktop.
Save savasdersimcelik/b35094b4d87d7fcfc8bd4f31bf278edd to your computer and use it in GitHub Desktop.
PHP Şans Sayı Algoritması
<?php
function sansliSayi($param)
{
$sayi = 2;
$deger = $param;
if ($sayi>$param) {
return true;
}
if ($param%$sayi == 0){
return false;
}
$deger -= $deger/$sayi;
$sayi++;
return sansliSayi($deger);
}
$sayac = 0;
for ($i=0; $i < 100000; $i++) {
if (sansliSayi($i)) {
$sayac++;
}
}
echo $sayac;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment