+ 1
Iâm a beginner
The first question is to write a method in Ruby that takes in a number as a parameter and prints âThis number is evenâ if the number is even or âThis number is oddâ If itâs odd.
3 Answers
+ 2
you can do this with if statements, for example, you make an input field then you can say if the number is 1,3,5,7, etc, the output will be odd and same for even
+ 2
Make an initial attempt and share your code. If you get stuck people can help.
0
thank you! here is what I have initially:
def even?(x)
puts "The number is even"
end
even?(8)
def odd?(x)
puts "The number is odd"
end
odd?(7)