Skip to content

Latest commit

 

History

History
61 lines (36 loc) · 600 Bytes

Return_the_closest_number_multiple_of_10.md

File metadata and controls

61 lines (36 loc) · 600 Bytes

CodeWars Python Solutions


Return the closest number multiple of 10

Given a number return the closest number to it that is divisible by 10.

Example Input

22
25
37

Expected Output

20
30
40

Given Code

def closest_multiple_10(i):
    pass

Solution 1

def closest_multiple_10(i):
    return i - i % 10 if i % 10 < 5 else i - i % 10 + 10

Solution 2

def closest_multiple_10(i):
    return round(i, -1)

See on CodeWars.com