n schoolchildren divide 𝑘k apples evenly, the residue remains in the basket. How many apples remains in the basket?
Input
Two integers 𝑛n and 𝑘k not greater than 15001500 — rarely happens in school more pupils, and where to find such a basket?
Output
Print the number of apples in the basket.
Example
Inputcopy | Outputcopy |
---|---|
3 14 | 2 |
Inputcopy | Outputcopy |
---|---|
10 100 | 0 |
Solutions:
import java.util.Scanner;
public class ApplesDivision {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int k = scanner.nextInt();
scanner.close();
int remainder = k % n;
System.out.println(remainder);
}
}