Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
wucututa authored Dec 8, 2020
1 parent 844e53f commit 20d9740
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions exp1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#1 Cho các phần tử từ 0 tới 10. In ra các phần tử chẵn(sử dụng hàm step)
0.step(10,2) do |v|
puts v
end

puts ""

#2 Tỉnh tổng của các phần tử từ 20 tới 50
x=0
for i in 20..50
x += i
end
puts x
#3 Cho String str = "hello". Uppercase từ đầu tiên của string trên
str = "hello"
puts str.capitalize

mang= Array(0..10)
mang.select do |z|
if(z%2==1)
puts z
end
end

0 comments on commit 20d9740

Please sign in to comment.