Project Euler Solutions by Ross Marks

<?php
/*****************************
 * ProjectEuler - Problem 31
 * By Ross Marks
 *****************************
 * In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:
 * 
 * 1p, 2p, 5p, 10p, 20p, 50p, £1 (100p) and £2 (200p).
 * It is possible to make £2 in the following way:
 * 
 * 1×£1 + 1×50p + 2×20p + 1×5p + 1×2p + 3×1p
 * How many different ways can £2 be made using any number of coins?
 ****************************/

$awns 0;

for(
$a 0$a <= 200$a++){             // 1p
  
for($b 0$b <= 100$b++){           // 2p
    
for($c 0$c <= 40$c++){          // 5p
      
for($d 0$d <= 20$d++){        // 10p
        
for($e 0$e <= 10$e++){      // 20p
          
for($f 0$f <= 4$f++){     // 50p
            
for($g 0$g<= 2$g++){    // 1 pound

              
$a1 $a 1;
              
$b1 $b 2;
              
$c1 $c 5;
              
$d1 $d 10;
              
$e1 $e 20;
              
$f1 $f 50;
              
$g1 $g 100;

              
$total $a1+$b1+$c1+$d1+$e1+$f1+$g1;
              if(
$total == 200){
                
//echo "$total: $a x 1p, $b x 2p, $c x 5p, $d x 10p, $e x 20p, $f x 50p, $g x £1\n";
                
$awns++;
                
//break;
              
}

            }
          }
        }
      }
    }
  }
}
$awns ++; // add 1 for £2 coin
echo "Answer: $awns";

?>