diff --git a/lab3_task1_funcation_block_arg/main.rb b/lab3_task1_funcation_block_arg/main.rb index 6f150bb..c03b79e 100644 --- a/lab3_task1_funcation_block_arg/main.rb +++ b/lab3_task1_funcation_block_arg/main.rb @@ -43,6 +43,12 @@ def minimal_even_element(array) end +def prime_divisors(number) + require 'prime' + (2..number).select { |x| number % x == 0 && Prime.prime?(x) } +end + + # Ex array = [5, 3, 8, 1, 7] puts "Indices in order of decreasing elements:" @@ -59,3 +65,7 @@ puts elements_between_first_and_last_max(array).join(", ") array = [5, 2, 8, 3, 7] puts "Minimal even element:" puts minimal_even_element(array) + +number = 28 +puts "Prime divisors:" +puts prime_divisors(number).join(", ")