leetle

Daily challenge for 2026-11-06

675. Round Cash to Nickel

Given a non-negative integer cents representing a monetary amount in cents, round it to the nearest multiple of 5 cents (as commonly done in cash transactions when one-cent coins are discontinued).

If the remainder when divided by 5 is 1 or 2, round down to the nearest multiple of 5. If the remainder is 3 or 4, round up to the nearest multiple of 5. If it is already a multiple of 5, return it unchanged. Note that since amounts are integer cents, no half-way ties occur.

Constraints:
The amount is an integer number of cents from 0 to 1,000,000,000. Return an integer number of cents. Because the input is integral, there is no halfway tie between consecutive multiples of five.

Example:
Input: cents = 97
Output: 95

Run this challenge interactively in Python or JavaScript when the app loads.