Skip to content

Instantly share code, notes, and snippets.

@dinhhuydh
Created November 30, 2017 03:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dinhhuydh/230e1cd6859c4a71999d2339bdb73e05 to your computer and use it in GitHub Desktop.
Save dinhhuydh/230e1cd6859c4a71999d2339bdb73e05 to your computer and use it in GitHub Desktop.
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
# [3,4,5] => 1
# [2,6,7] => 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment