Game Overview
Part of the Fundamentals section of Coddy's Ruby journey — lesson 54 of 88.
Challenge
EasyIn this chapter, you'll build a customizable FizzBuzz game using methods, loops, and conditional logic.
To start, create a method called check_divisible that takes two arguments: number and divisor. The method should return true if the number is divisible by the divisor (no remainder), and false otherwise.
Read two numbers from input, convert them to integer values, and call your method with these values. Print the returned result.
For example, if the inputs are:
15
3The output should be:
trueIf the inputs are:
15
5The output should be:
trueIf the inputs are:
7
3The output should be:
falseTry it yourself
# Read input
number = gets.chomp.to_i
divisor = gets.chomp.to_i
# TODO: Create a method called check_divisible that takes two arguments:
# number and divisor. Return true if number is divisible by divisor, false otherwise.
# Call your method and print the result
puts check_divisible(number, divisor)All lessons in Fundamentals
4Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Logical Operators Part 42Variables and Data Types
Numbers and VariablesString Data TypeBoolean Data TypeSymbol Data TypeChecking Data TypesNaming ConventionsRecap - Variable Creation8Loops
For Loop with RangesWhile LoopBreakNextRecap - FactorialTimes LoopUntil LoopNested LoopsRecap - Dynamic Input3Operators Part 1
Arithmetic OperatorsModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators6Basic IO
Output with putsOutput with print and pOutput With VariablesInput with getsChomp MethodType ConversionRecap - Age CalculatorRecap - True or False