Round up to the next multiple of 5
Given an integer as input, can you round it to the next (meaning, "greater than or equal") multiple of 5?
function roundToNext5(n: number): number {
return n + (5 - n) % 5;
}
console.log(roundToNext5(100));
package main
import "fmt"
func roundToNext5(n int) int {
return n + (5 - n % 5) % 5
}
func main() {
fmt.Println(roundToNext5(100))
}
def round_to_next_5(n):
return n + (5 - n) % 5
print(round_to_next_5(100))
function roundToNext5($n) {
return $n + (5 - $n % 5) % 5;
}
echo roundToNext5(100);
Go to Kata
Want us to give you some help with your business? No problem, here's a video on who we can help, and how, along with our calendar so you can book in a call to discuss us working together.
Let's see