Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.1 kB
4
Indexable
Never
<?php
function isEven($number){
    if($number % 2 == 0 ){
        return true;
    }
    return false;
}
function biggerThanTwo($number){
    if($number > 2){
        return isEven($number);
    }
}
function isPrime($number){
    $found = true;
    for($i=2;$i < $number;$i++){
        if($number % $i == 0){
            $found = false;
        }
    }
    return $found;
}
function allPrimeLess($number){
    $primes = [];
    for($i = 2;$i <= $number ; $i++){
        if(isPrime($i)){
            $primes[] = $i;
        }
    }
    return $primes;
}
function goldenBakh($number){
    if(biggerThanTwo($number)){
        $primes = allPrimeLess($number);
        // var_dump($primes); 
        // die();
        $arrayPrimes = [];
        for($i = 0 ; $i < count($primes) ;$i++ ){
            for($j = 0 ; $j < count($primes) ; $j++){
                if($primes[$i] + $primes[$j] == $number){
                    $arrayPrimes =  "(". $primes[$i].",".$primes[$j].")<br>";
                }
            }
        }
    }
}
goldenBakh(8);