Java – How to Check if integer is multiple of a number?
Problem Statement
You need to check if the integer number is a multiple of a number in Java.
Solution
Use the modulus operator and check the remainder to find it out. Below is a sample code snippet demonstrating how to find if the number is a multiple of 4.
public class Main {
public static void main(String[] args) {
int acinput = 12;
int result = acinput %4;
System.out.println(result);
}
}
Leave Your Comment