Solved a few more problems

003: php
005: php, ruby
006: php, ruby, c
This commit is contained in:
FuryFire
2012-03-06 14:21:54 +01:00
parent 15e919438d
commit 9dd9d918bf
9 changed files with 146 additions and 0 deletions

17
ProjectEuler/005/desc.yml Normal file
View File

@ -0,0 +1,17 @@
title: What is the smallest number divisible by each of the numbers 1 to 20?
url: http://projecteuler.net/problem=5
desc: |
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
solution: |
See code
solutions:
solve.php:
desc: Basic solution
language: php
solve.rb:
desc: Basic solution in Ruby
language: ruby

View File

@ -0,0 +1,12 @@
<?php
for($i=20;true;$i+=20) {
$div = 19;
while(!($i % $div)) {
$div--;
if($div == 0) {
echo $i;
die;
}
}
}

10
ProjectEuler/005/solve.rb Normal file
View File

@ -0,0 +1,10 @@
max = 0;
(100..1000).each do |num1|
(100..1000).each do |num2|
sum = num1 * num2
if( sum > max and sum.to_s.reverse == sum.to_s)
max = sum
end
end
end
print max