https://www.codewars.com/kata/55d1d6d5955ec6365400006d
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Given an integer as input, can you round it to the next (meaning, "greater than or equal") multiple of 5?
Examples:
input: output:
0 -> 0
2 -> 5
3 -> 5
12 -> 15
21 -> 25
30 -> 30
-2 -> 0
-5 -> -5
etc.
Input may be any positive or negative integer (including 0).
You can assume that all inputs are valid integers.
코드
function roundToNext5(n){
return Math.ceil(n / 5) * 5;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Grasshopper - Check for factor (8 kyu) / JavaScript (0) | 2023.03.05 |
---|---|
[Codewars] Is it even? (8 kyu) / JavaScript (0) | 2023.03.05 |
[Codewars] You Can't Code Under Pressure #1 (8 kyu) / JavaScript (0) | 2023.03.04 |
[Codewars] L1: Set Alarm (8 kyu) / JavaScript (0) | 2023.03.03 |
[Codewars] I love you, a little , a lot, passionately ... not at all (8 kyu) / JavaScript (0) | 2023.03.03 |
댓글