Created
November 22, 2017 18:02
-
-
Save savasdersimcelik/b35094b4d87d7fcfc8bd4f31bf278edd to your computer and use it in GitHub Desktop.
PHP Şans Sayı Algoritması
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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