Project Euler Solutions by Ross Marks

<?php
/*****************************
 * ProjectEuler - Problem 23
 * By Ross Marks
 *****************************
 * A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
 * 
 * A number n is called deficient if the sum of its proper divisors is less than n and it is called abundant if this sum exceeds n.
 * 
 * As 12 is the smallest abundant number, 1 + 2 + 3 + 4 + 6 = 16, the smallest number that can be written as the sum of two abundant numbers is 24. By mathematical analysis, it can be shown that all integers greater than 28123 can be written as the sum of two abundant numbers. However, this upper limit cannot be reduced any further by analysis even though it is known that the greatest number that cannot be expressed as the sum of two abundant numbers is less than this limit.
 * 
 * Find the sum of all the positive integers which cannot be written as the sum of two abundant numbers.
 ****************************/

$awns 0;

$to_remove = array();
$abundents = array();

echo 
"[+] Creating number array\n";
for (
$i 0$i <= 28123$i++){ 
    
$to_remove[$i] = 1;
}

echo 
"[+] Finding abundent no's\n";
for(
$no 1$no <= 30000$no++){
    
$divs proper_divisors($no);
    
$count 0;
    foreach(
$divs as $toadd){
        
$count += $toadd;
    }
    
$pad perfect($no$count);
    if(
$pad == "a"){
        
$abundents[] = $no;
    }
}
    
echo 
"[+] Removing abundent sums\n";
foreach(
$abundents as $no1){
    foreach(
$abundents as $no2){
        
$exists $no1+$no2;
        if(@
$to_remove[$exists] == 1){
            
$to_remove[$exists] = 0;
        }
    }
}

echo 
"[+] Calculating awnser\n";
foreach(
$to_remove as $no => $bool){
    if(
$bool == 1){
        
$awns bcadd($awns$no);
    }
}

echo 
"[=] $awns";

/***
 * FUNCTIONS BELOW
 */

function proper_divisors($number){
    for (
$n 1$n ceil($number/2)+1$n++)
        if (!(
$number $n))
            
$divisors[] = $n;

    return 
$divisors;
}

function 
perfect($number$div_count){
    if(
$number == $div_count){ //perfect number
        
return "p";
    }else if(
$number $div_count){ // abundent
        
return "a";
    }else if(
$number $div_count){ // deficient
        
return "d";
    }
}

?>