Skip to content

Instantly share code, notes, and snippets.

#1. sum of even numbers
# count_even(a)
# [1,2,3] => 2
# [1,2,4] => 6
# 2. Return names with 'H' at first letter
# ['Haa', 'aa', 'kkk] => ['Haa']
@dinhhuydh
dinhhuydh / Ruby loop exercises
Created November 30, 2017 03:51
Ruby loop exercises
# 1. Returns the elements at even positions
# a = [5,6,7,3]
# => [5,7] (5 at index 0, 7 at index 2)
# 2. Calculate the fibonaci at n th (1,1,2,3)
# fibonaci(2) => 1
# fibonaci(4) => 3
# 3. Count how many number 4 in array