Skip to content

Instantly share code, notes, and snippets.

@bdougie
Last active January 26, 2018 05:45
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 bdougie/ae926e797416c434c1396a474e2d3d5a to your computer and use it in GitHub Desktop.
Save bdougie/ae926e797416c434c1396a474e2d3d5a to your computer and use it in GitHub Desktop.
# the problem is return the wrong answer, set a breakpoint to find out what is wrong
def powersOfTwo(n)
newArr = []
(0..n).to_a.each_with_index do |x, i|
# set a print to see what s happening
newArr.push(2*i)
end
newArr
end
# powersOfTwo(2)
# [1,2,4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment