by CodeChum Admin
We Filipinos are quite known for the habit of leaving at least one of the many pieces of food on the plate as it can't be equally divided among all at most times. Just like when 3 people decide to eat a pizza of 10 slices, there will often be at least one slice left on the box. To accurately show just how many pieces of things are left when divided by a certain number, we code it using modulo.
Care to do it for me?
Input
A line containing two integers separated by a space.
10·3
Output
A single line containing an integer.
1
import java.util.Scanner;
class App {
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
int n1 = keyBoard.nextInt();
int n2 = keyBoard.nextInt();
System.out.print((n1 % n2));
keyBoard.close();
}
}
Comments
Leave a comment