Skip to content

Instantly share code, notes, and snippets.

@RickGriff
Created December 11, 2017 22:00
Show Gist options
  • Save RickGriff/be8fd8f5a8ed3372ff7ee60345bdf80f to your computer and use it in GitHub Desktop.
Save RickGriff/be8fd8f5a8ed3372ff7ee60345bdf80f to your computer and use it in GitHub Desktop.
Codewars Challenge 2 - Count by X
#Create a function with two arguments that will return a list of length (n) with multiples of (x).
#Assume both the given number and the number of times to count will be positive numbers greater than 0.
#Return the results as an array (or list in Python, Haskell or Elixir).
#Examples:
#count_by(1,10) should return [1,2,3,4,5,6,7,8,9,10]
#count_by(2,5) should return [2,4,6,8,10]
#My Solution:
def count_by(x, n)
(1..n).map { |item| item * x }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment