G – Divide the apples – 2

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

InputcopyOutputcopy
3
14
2
InputcopyOutputcopy
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);
    }
}

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top