Restructuring
This commit is contained in:
20
solutions/ProjectEuler/005/desc.yml
Normal file
20
solutions/ProjectEuler/005/desc.yml
Normal file
@ -0,0 +1,20 @@
|
||||
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
|
||||
solve.js:
|
||||
desc: Basic solution for NodeJS
|
||||
language: js
|
11
solutions/ProjectEuler/005/solve.js
Normal file
11
solutions/ProjectEuler/005/solve.js
Normal file
@ -0,0 +1,11 @@
|
||||
for(i=20;true;i+=20) {
|
||||
div = 19;
|
||||
|
||||
while(!(i % div)) {
|
||||
div--;
|
||||
if(div == 0) {
|
||||
console.log( i );
|
||||
process.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
12
solutions/ProjectEuler/005/solve.lua
Normal file
12
solutions/ProjectEuler/005/solve.lua
Normal file
@ -0,0 +1,12 @@
|
||||
i=0
|
||||
while(true) do
|
||||
i = i + 20
|
||||
div = 19
|
||||
while((i % div) == 0) do
|
||||
div = div - 1
|
||||
if(div == 0) then
|
||||
print(i)
|
||||
os.exit()
|
||||
end
|
||||
end
|
||||
end
|
12
solutions/ProjectEuler/005/solve.php
Normal file
12
solutions/ProjectEuler/005/solve.php
Normal file
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
for($i=20;true;$i+=20) {
|
||||
$div = 19;
|
||||
|
||||
while(!($i % $div)) {
|
||||
$div--;
|
||||
if($div == 0) {
|
||||
echo $i;
|
||||
die;
|
||||
}
|
||||
}
|
||||
}
|
13
solutions/ProjectEuler/005/solve.rb
Normal file
13
solutions/ProjectEuler/005/solve.rb
Normal file
@ -0,0 +1,13 @@
|
||||
i = 0
|
||||
while (true)
|
||||
i = i + 20
|
||||
div = 19
|
||||
|
||||
while((i % div) == 0)
|
||||
div = div - 1
|
||||
if(div == 0) then
|
||||
puts i
|
||||
exit
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user