Determine that the value is a multiple of 〇 in Ruby

Hello. I started using Ruby, but I couldn't find a way to check if any value was a multiple, so I made a note.

To distinguish

Use%, which gives the remainder of A divided by B. If it is a multiple of the specified value, 0 should be output.



a = 10
b = 5
if a % b == 0
 puts "#{a}Is a multiple of 5."
 puts "#{a}Is not a multiple of 5."

Recommended Posts

Determine that the value is a multiple of 〇 in Ruby
Sample program that returns the hash value of a file in Java
Count the number of occurrences of a string in Ruby
[Ruby / Rails] Set a unique (unique) value in the class
Review the basic knowledge of ruby that is often forgotten
A program that counts the number of words in a List
Form that receives the value of the repeating item in Spring MVC
I want to change the value of Attribute in Selenium of Ruby
Find the difference from a multiple of 10
The story of making a binding for libui, a GUI library for Ruby that is easy to install
I tried to make a parent class of a value object in Ruby
[Ruby] Processing with multiple colons. A class that utilizes the module namespace.
How to change the value of a variable at a breakpoint in intelliJ
Summary: Implementation of a function that switches the logical value when a link is clicked [for own output]
[Java] You might be happy if the return value of a method that returns null is Optional <>
The ruby version is managed in the .rbenv / version file
A description of Interface that is often mistaken
Create a native extension of Ruby in Rust
I want to get the value in Ruby
Call a method of the parent class by explicitly specifying the name in Ruby
Initialize Ruby array with 0 like Java, that is, set the default value to 0
[Java] Where is the implementation class of annotation that exists in Bean Validation?
[Ruby on Rails] Implement a pie chart that specifies the percentage of colors
[Note] [Beginner] How to write when changing the value of an array element in a Ruby iterative statement
[Ruby] The role of subscripts in learning elements in arrays
A small story that is sometimes useful in Maven
Calculate the difference between numbers in a Ruby array
Verification value error that occurred in a clustering environment
Display the average value of the evaluation as a star
Find the approximate value of log (1 + x) in Swift
Get the URL of the HTTP redirect destination in Ruby
How is the next value of the Time object correct?
The story that .java is also built in Unity 2018
[Ruby] I want to make a program that displays today's day of the week!
Find the greatest common divisor and least common multiple of any number of integers in Ruby
Install multiple submit buttons in Rails View to get the value of the pressed button
Write a test by implementing the story of Mr. Nabeats in the world with ruby
[ruby] How to assign a value to a hash by referring to the value and key of another hash
The end of catastrophic programming # 03 "Comparison of integers, if" a> b ", assume that it is" a --b> 0 ""
Sample code to assign a value in a property file to a field of the expected type
What is a Ruby module?
A quick explanation of the five types of static in Java
Check the dependency of a specific maven artifact in Coursier
A program (Java) that outputs the sum of odd and even numbers in an array
What is the representation of domain knowledge in the [DDD] model?
A memo of the program that allows you to realize that the probability of dice rolling is about 1/6
(Ruby on Rails6) Display of the database that got the id of the database
How to retrieve the hash value in an array in Ruby
Multiplication in a Ruby array
A note about the seed function of Ruby on Rails
The nth and n + 1st characters of a Ruby string
[Ruby] How to retrieve the contents of a double hash
Create a database of all the books that have been circulating in Japan in the last century
Judgment of fractions in Ruby
[Swift] Get the timing when the value of textField is changed
[Ruby] Thinking when there is no receiver in front of the method (it looks like)
Find the number of days in a month with Kotlin
[Rails] How to temporarily save the request URL of a user who is not logged in and return to that URL after logging in
A story that a Ruby beginner made and released a LINE BOT that tells the train time in 2 months
[Spring Data JPA] Custom ID is assigned in a unique sequence at the time of registration.
The story that a model is not a "correct representation of the real world" / the need for a bounded context