← Accenture questions
CodingEasy to Moderate

Round a given number to the nearest multiple of 10

Filed under Accenture

Free read 2 of 3

Confirm how to handle negative numbers and if the input is always an integer.

The question

Given an integer, round it to the nearest multiple of 10. If the last digit is 5 or greater, round up; otherwise, round down.

Constraints

  • Input is an integer
  • Rounding logic: >= 5 rounds up, < 5 rounds down

Examples

Input
23
Output
20
Why
Last digit 3 < 5, round down.
Input
25
Output
30
Why
Last digit 5 >= 5, round up.

Approach

  1. Confirm how to handle negative numbers and if the input is always an integer.

Solution

O(1) time, O(1) space

Python
def round_to_ten(n):
    # Add 5 to handle the rounding threshold
    return (n + 5) // 10 * 10

Tips

  • What they are testing: Tests edge cases like negative numbers and numbers already ending in 0.
  • Common mistake: Forgetting that negative numbers round differently (e.g., -25 might round to -20 or -30 depending on requirements).

Related Accenture questions

Collected from public candidate posts and coding forums. Updated Nov 2026.