Class: Factorial::Gcf
- Inherits:
-
Array
- Object
- Array
- Factorial::Gcf
- Defined in:
- lib/factorial/gcf.rb
Instance Method Summary collapse
-
#initialize(*number_array) ⇒ Gcf
constructor
A new instance of Gcf.
- #manage_the_array ⇒ Object
Constructor Details
#initialize(*number_array) ⇒ Gcf
Returns a new instance of Gcf.
4 5 6 7 |
# File 'lib/factorial/gcf.rb', line 4 def initialize(*number_array) @num_arr = *number_array self << manage_the_array end |
Instance Method Details
#manage_the_array ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/factorial/gcf.rb', line 9 def manage_the_array gcd = 1 (0..@num_arr.length - 1).each do |i| gcd = gcd_inner_method(@num_arr[i], @num_arr[i + 1]) @num_arr[i + 1] = gcd end gcd end |