Skip to content

Instantly share code, notes, and snippets.

@ednasawe
Created September 30, 2016 19:13
Show Gist options
  • Save ednasawe/37a47d1f7d1461eafa26bcc6cf22e0c1 to your computer and use it in GitHub Desktop.
Save ednasawe/37a47d1f7d1461eafa26bcc6cf22e0c1 to your computer and use it in GitHub Desktop.
Ed
[1] pry(main)> def prdarray (arr)
[1] pry(main)* initial = 1
[1] pry(main)* arr.each do |i|
[1] pry(main)* initial=initial*i
[1] pry(main)*
[1] pry(main)* if (i=0)
[1] pry(main)* return puts "Elements in array must be non zero"
[1] pry(main)* end
[1] pry(main)* end
[1] pry(main)* new_arr=[]
[1] pry(main)* arr.each do |d|
[1] pry(main)* y = initial/d
[1] pry(main)* new_arr << y
[1] pry(main)* end
[1] pry(main)* new_arr
[1] pry(main)* end
(pry):6: warning: found = in conditional, should be ==
=> :prdarray
[2] pry(main)> prdarray [3,4,5]
Elements in array must be non zero
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment