Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_time_limit(0);
- function asal($sayi)
- {
- $kok=sqrt($sayi);
- if ($sayi == 1 || $sayi == 0) {
- return 0;
- }
- for ($i=2; $i<=$kok; $i++){
- if($sayi % $i==0) return 0;
- }
- return 1;
- }
- function asalCarpanlar($param)
- {
- $asallar = array();
- for ($i=2; $i <= $param; $i++) {
- if ($param%$i==0) {
- if (asal($i)) {
- array_push($asallar, $i);
- }
- }
- }
- return $asallar;
- }
- function carpanlarToplami($param)
- {
- $asallar = asalCarpanlar($param);
- $deger = 0;
- foreach ($asallar as $asal) {
- while($param%$asal==0){
- $spl = str_split($asal);
- foreach ($spl as $value) {
- $deger = $deger+$value;
- }
- $param= $param/ $asal;
- }
- }
- return $deger;
- }
- $sayac = 0;
- for ($i=1; $i < 100; $i++) {
- $sayi = str_split($i);
- if (asal($i) == false) {
- if (carpanlarToplami($i) == array_sum($sayi)) {
- echo $i . '<br/>';
- $sayac++;
- }
- }
- }
- echo $sayac;
- ?>
Add Comment
Please, Sign In to add comment