+ 1

I have list of prime numbers , but it keeps saying there's an error

The code was if gets = 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,51,53,57,59,61,67,71,73,79,83,87,89,91,97 puts "prime number" end

8th Jul 2020, 10:18 AM
Marion Angeles
3 Respostas
+ 5
May be you want something like this: inp = gets.chomp().to_i nums = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,51,53,57,59,61,67,71,73,79,83,87,89,91,97] if nums.include?(inp) puts "prime number" end
8th Jul 2020, 10:52 AM
Lothar
Lothar - avatar
0
Gets is used to input string so if you want to compare all int values given here you have to put or operator between every value That's what I think from this code
8th Jul 2020, 10:22 AM
Barkha Joshi
Barkha Joshi - avatar
0
Lothar it works! Thank you so much.
8th Jul 2020, 11:53 AM
Marion Angeles