Restructuring

This commit is contained in:
2024-07-01 13:49:44 +00:00
parent f11b705ef0
commit 8d60e1b905
194 changed files with 1296 additions and 112 deletions

View File

@ -0,0 +1,26 @@
title: Add all the natural numbers below one thousand that are multiples of 3 or 5.
url: http://projecteuler.net/problem=1
desc: |
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
solution: |
Loop numbers from 1-1000 - Use mod to find the multiples
solutions:
solve.php:
desc: Basic solution
language: php
solve.rb:
desc: Basic solution in Ruby
language: ruby
solve.c:
desc: ANSI C solution (Tested with TCC)
language: c
solve.js:
desc: NodeJS solution
language: javascript
solve.lua:
desc: Basic solution
language: lua

View File

@ -0,0 +1,15 @@
#include <stdio.h>
int main( )
{
int sum = 0;
int i = 0;
for(i = 1; i < 1000; i++)
{
if(i % 3 == 0 || i % 5 == 0)
{
sum += i;
}
}
printf( "%i", sum );
}

View File

@ -0,0 +1,9 @@
sum = 0;
i = 0;
for(i=1; i<1000;i++) {
if(i % 3 == 0 || i % 5 == 0) {
sum += i;
}
}
console.log(sum);

View File

@ -0,0 +1,7 @@
sum = 0
for i=1,999 do
if i % 3 == 0 or i % 5 == 0 then
sum = sum + i
end
end
print(sum)

View File

@ -0,0 +1,10 @@
<?php
$sum = 0;
$i = 0;
for($i=1; $i<1000;$i++) {
if($i % 3 == 0 OR $i % 5 == 0) {
$sum += $i;
}
}
echo $sum;

View File

@ -0,0 +1,7 @@
sum = 0
(1..1000).each do |i|
if(i % 3 == 0 or i % 5 == 0)
sum += i
end
end
puts sum