Project Euler 2
- Sara know
- arthimetic (+, – , *, /, %)
- comparision
=, !=, < , <=, >, >=
- logical
and or not
- Remember
Remember 10 as a or a = 10
- Calculate
calculate 10 + 20 and remember as a or a = 10 + 20
- Problem
- Conversation
Hi sara,
a = 1
b = 2
result = 2
until a + b < 100
c = a + b
if c % 2 == 0 then
result = result + c
a = b
b = c
say result
Project Euler 5
Hi Sara
start = 1
end = 4
index = 1
# found factorial
max = 1
until index <= end
max = max * index
index = index + 1
result = 0
index = end
until index <= max:
# lets find if index is divisible by all numbers from 1 (start) to 5 (end)
is_divisible_by_all = True
counter = start
until counter <= end
if index % counter != 0:
is_divisible_by_all = False
get out of this unitl
if is_divisble_by_all:
result = index
say result
exit
index = index + end
Project Euler 6
Hi sara
start = 1
end = 10
square_sum = 0
sum_of_squares = 0
until start <= end
sum_of_squares = sum_of_squares + start * start
start = start + 1
sum = end * (end + 1) // 2
square_sum = sum * sum
say square_sum - sum_of_squares
- Make sara to find if the
- number is prime or not
- number is pallendrome or not
Like this:
Like Loading...