Skip to content

Instantly share code, notes, and snippets.

@savasdersimcelik
Created November 20, 2017 11:27
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/aecc034292c3b0f609439fdd380800fd to your computer and use it in GitHub Desktop.
Save savasdersimcelik/aecc034292c3b0f609439fdd380800fd to your computer and use it in GitHub Desktop.
<?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