+ 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
3 Respuestas
+ 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
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
0
Lothar it works! Thank you so much.