Created
November 20, 2017 11:27
-
-
Save savasdersimcelik/aecc034292c3b0f609439fdd380800fd to your computer and use it in GitHub Desktop.
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 | |
/** | |
* Author : Savaş Dersim ÇELİK | |
* Version: 1.0.0 | |
* Web: http://webinyo.com | |
* Mail: savasdersimcelik@gmail.com | |
* Description : PHP ile Tekin Sayılar Algoritması | |
*/ | |
function tekinsayi($param) | |
{ | |
$karakter = str_split($param); | |
$kSayi = 0; | |
foreach ($karakter as $key => $value) { | |
if ($value != 0 && ($param % $value == 0)) { | |
$kSayi++; | |
} | |
if ($kSayi == strlen($param)) { | |
return true; | |
} | |
} | |
} | |
$sayac = 0; | |
for ($i=1; $i < 100000; $i++) { | |
if (tekinsayi($i)) { | |
$sayac++; | |
} | |
} | |
echo $sayac; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment