2nd exercise
This commit is contained in:
parent
89a7d27ed5
commit
3dc8c60ebd
15
ruby_algo/ex2.rb
Normal file
15
ruby_algo/ex2.rb
Normal file
|
@ -0,0 +1,15 @@
|
|||
max = 4_000_000
|
||||
a, b = 1, 2
|
||||
c = 3
|
||||
sum = 0
|
||||
|
||||
while b < max do
|
||||
sum += b if b % 2 == 0
|
||||
c = (a + b)
|
||||
puts "#{c} = #{a} + #{b}"
|
||||
a, b = b, c
|
||||
|
||||
end
|
||||
|
||||
|
||||
puts sum
|
Loading…
Reference in a new issue