Update examples

This commit is contained in:
Daniel M 2022-02-04 12:26:02 +01:00
parent 22634af554
commit 56665af233
5 changed files with 23 additions and 19 deletions

View File

@ -7,7 +7,7 @@
sum <- 0;
i <- 0;
loop i < 1_000; i = i + 1 {
if i % 3 == 0 | i % 5 == 0 {
if i % 3 == 0 || i % 5 == 0 {
sum = sum + i;
}
}

View File

@ -10,14 +10,12 @@ sum <- 0;
a <- 0;
b <- 1;
tmp <- 0;
loop a < 4_000_000 {
if a % 2 == 0 {
sum = sum + a;
}
tmp = a;
tmp <- a;
a = b;
b = b + tmp;
}

View File

@ -4,23 +4,15 @@
//
// Correct Answer: 906609
res <- 0;
tmp <- 0;
num <- 0;
num_rev <- 0;
i <- 100;
k <- 100;
loop i < 1_000; i = i + 1 {
k = 100;
k <- 100;
loop k < 1_000; k = k + 1 {
num_rev = 0;
num = i * k;
tmp = num;
num_rev <- 0;
num <- i * k;
tmp <- num;
loop tmp {
num_rev = num_rev*10 + tmp % 10;

View File

@ -5,12 +5,10 @@
num <- 20;
should_continue <- 1;
i <- 2;
loop should_continue {
should_continue = 0;
i = 20;
i <- 20;
loop i >= 2; i = i - 1 {
if num % i != 0 {
should_continue = 1;

16
examples/euler5.py Normal file
View File

@ -0,0 +1,16 @@
# 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?
#
# Correct Answer: 232_792_560
num = 20
while True:
for i in range(20, 2, -1):
if num % i != 0:
break
else:
break
num = num + 20
print(num)