Created
September 29, 2016 20:16
-
-
Save kharioki/bd21cb20a309777f7857a8c95e021bad to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def product_except?(d) | |
| e = [] | |
| startvalue = 0 | |
| endvalue = d.length | |
| product = d.inject(1){|first,n| first * n} | |
| result = [] | |
| while startvalue < endvalue | |
| result.push(product/ d[startvalue]) | |
| startvalue = startvalue + 1 | |
| end | |
| puts "#{result}" | |
| end | |
| product_except?([1,2,3,4,5,6,7,8,9]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment