Created
November 17, 2017 22:50
-
-
Save savasdersimcelik/e449a533dbcf784b49a8e7f380a193c8 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 : Harshad Sayılarını Listeleyen Algoritma | |
*/ | |
error_reporting(0); | |
function harshad($param) | |
{ | |
$parcala = str_split($param); | |
$topla = 0; | |
if (strlen($param) < 2) { | |
return false; | |
} | |
for ($i=0; $i < count($parcala); $i++) { | |
$topla = $topla + $parcala[$i]; | |
} | |
if ($param % $topla == 0) { | |
return true; | |
} | |
} | |
$sayac = 0; | |
for ($s=0; $s < 200000; $s++) { | |
if (harshad($s)) { | |
$sayac++; | |
} | |
} | |
echo $sayac; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment