0

why y is always 0 no matter what input I enter? please help

# outputs the number with the most even divisors x=gets.to_i y=gets.to_i k1=0 k2=0 for i in 1..x if x%i==0 if i%2==0 k1+=1 end end end for i in 1..y if y%i==0 if i%2==0 k2+=1 end end end if k1==k2 puts "#{x} #{y}" elsif k1>k2 puts x elsif k2>k1 puts y end

12th Nov 2016, 11:51 AM
Catalin Dervesteanu
Catalin Dervesteanu - avatar
2 Antworten
+ 5
Well didn't quiet understand what are you referring to but I tried with input as 18 12 18(2,6). 12(2,4,6). and it outputs 12 so I guess y is not 0. If you are using solo learn compiler then enter first number then go to next line that is press enter then input second number and then submit.
13th Nov 2016, 5:11 PM
Megatron
Megatron - avatar
0
thanks, didn't know it has to be on the second line
15th Nov 2016, 6:42 AM
Catalin Dervesteanu
Catalin Dervesteanu - avatar