Given an integer as input, can you round it to the next (meaning, "higher") 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.

Difficulty: EASY
Tags: Fundamentals

Starter code:
def round_to_next5(n):
	

Solutions:
def round_to_next5(n):
	return n + (5 - n) % 5


def round_to_next5(n):
	while n % 5 != 0:
		n += 1
	return n


import math

def round_to_next5(n):
	return math.ceil(n / 5.0) * 5


def round_to_next5(n):
	return 5 * ((n + 4) / 5)


def round_to_next5(n):
	rem = n % 5
	return n + (5 - rem if rem else 0)


def round_to_next5(n):
	return n if n % 5 == 0 else round_to_next5(n + 1)


from math import ceil

def round_to_next5(n):
	return ceil(n / 5) * 5


def round_to_next5(n):
	(x, y) = divmod(n, 5)
	return (x + (y > 0)) * 5


from itertools import count

def round_to_next5(n):
	return next((val for val in count(n) if val % 5 == 0))


round_to_next5 = lambda n: n if n % 5 == 0 else (n / 5 + 1) * 5


def round_to_next5(n):
	r = n % 5
	return 5 + (n - r) if r != 0 else n


from math import ceil

def round_to_next5(n):
	return 5 * ceil(n / 5)
	return n + 5 - (n % 5 or 5)
	return (n + 4) // 5 * 5


import math

def round_to_next5(n):
	return int(math.ceil(n / 5)) * 5


def round_to_next5(n):
	if n % 5:
		return n + (5 - n % 5)
	else:
		return n


round_to_next5 = lambda n: n + -n % 5


def round_to_next5(n):
	return n / 5 * 5 + 5 * bool(n % 5)


def round_to_next5(n):
	return (n / 5 + (n % 5 != 0)) * 5


def round_to_next5(n):
	if n % 5 == 0:
		return n
	elif n % 5 != 0:
		while n % 5 != 0:
			n = n + 1
			if n % 5 == 0:
				return n
				break
print(round_to_next5(30))


def round_to_next5(n):
	return round(n / 5 + 0.49) * 5


def round_to_next5(n):
	return n - 1 - (n - 1) % 5 + 5


import math

def round_to_next5(n):
	x = math.ceil(n / 5) * 5
	return x


from math import ceil

def round_to_next5(n):
	return 5 * round(ceil(float(n) / 5))


def round_to_next5(n):
	if not n % 5:
		return n
	else:
		return round_to_next5(n + 1)


def round_to_next5(n):
	return n if n % 10 == 0 else n + -n % 5


def round_to_next5(n):
	(q, r) = divmod(n, 5)
	return n if not r else (q + 1) * 5


def round_to_next5(n):
	if n % 5 == 0:
		return n
	else:
		res = 0
		while (n + res) % 5:
			res += 1
		return n + res


def round_to_next5(n):
	if n % 5 != 0:
		while n % 5 != 0:
			n += 1
	return n
round_to_next5(-2)


def round_to_next5(n):
	if n % 5 == 0:
		return n
	else:
		return n + 5 - abs(n % 5)


def round_to_next5(n):
	for i in range(5):
		a = n + i
		if a / 5 == a // 5:
			return a


import math

def round_to_next5(n):
	res = 5 * math.floor(n / 5)
	if n < 0 and n != res:
		return res + 5
	elif n < 0 and n == res:
		return res
	return math.ceil(n / 5) * 5


def round_to_next5(n):
	if n % 5 == 0:
		return n
	a = n // 5
	return (a + 1) * 5


def round_to_next5(n):
	if n == 0:
		return 0
	if n % 5 == 0:
		return n
	sum1 = n // 5
	if sum1 == 0:
		return 5
	return (sum1 + 1) * 5


def round_to_next5(n):
	i = 5
	while True:
		x = i - n
		if x in range(0, 5):
			return i
		elif x < 0:
			i = i + 5
		elif x >= 5:
			i = i - 5
	return n


def round_to_next5(n):
	if n % 5:
		if n > 0:
			return 5 * int(n / 5) + 5
		else:
			return 5 * int(n / 5)
	else:
		return 5 * int(n / 5)


def round_to_next5(n, base=5):
	if n % 10 != 0:
		if n % 5 < 3:
			n += 2
		return base * round(n / base)
	return n


def round_to_next5(n):
	if n == 0:
		return 0
	elif n % 5 == 0:
		return n
	elif n > 0:
		return (int(n / 5) + 1) * 5
	else:
		return int(n / 5) * 5


def round_to_next5(n):
	a = n // 5 * 5
	b = a + 5
	if a == n:
		return n
	elif a > b:
		return a
	else:
		return b


def round_to_next5(n):
	i = 0
	if n == 0:
		return 0
	for i in range(20000):
		if 5 * (i + 1) >= n > 0:
			return 5 * (i + 1)
			break
		elif -5 * (i + 1) < n < 0:
			return -5 * i


def round_to_next5(n):
	cheat = [0, 1, 1, 1, 1]
	r = int(n / 5) + (cheat[n % 5] * n > 0)
	r = r * 5
	return r


def round_to_next5(n):
	if n % 5 == 0:
		return n
	while True:
		if (n + 1) % 5 == 0:
			return n + 1
		n += 1
	return n


def round_to_next5(n):
	result = n // 5 * 5
	if n - n // 5 * 5 > 5:
		return result - 5
	if n - n // 5 * 5 >= 1:
		return result + 5
	if n - n // 5 * 5 < 1:
		return result


def round_to_next5(n):
	counter = 0
	if n > 0:
		while n > counter:
			counter += 5
		return counter
	else:
		for i in range(n, -n + 1):
			if i % 5 == 0:
				return i


def round_to_next5(n):
	remainder = n % 5
	if remainder == 0:
		return n
	if remainder > 0:
		missing_value = 5 - remainder
		return n + missing_value


def round_to_next5(n):
	nearest_multiple = 5 * round(n / 5)
	if nearest_multiple < n:
		nearest_multiple = nearest_multiple + 5
	return nearest_multiple


import math

def round_to_next5(n):
	return n if n % 5 == 0 else math.floor(n / 5) * 5 + 5


def round_to_next5(n):
	for item in range(n, n + 5):
		if item % 5 == 0:
			return item


def round_to_next5(n):
	import math
	if n <= 0 and n > -5:
		output = 0
	elif n <= -5:
		output = math.ceil(n / 5) * 5
	else:
		output = math.ceil(n / 5) * 5
	return output


def round_to_next5(n):
	x = n % 5
	if x == 0:
		y = n
	else:
		y = n + (5 - x)
	return y


import string

def round_to_next5(n):
	if n % 5 != 0:
		return n + (5 - n % 5)
	return n


import numpy as np

def round_to_next5(n):
	if np.int(n / 5) * 5 == n:
		return n
	if np.int(n / 5) * 5 != n:
		return np.int(n / 5) * 5 + 5 * (n > 0)


def round_to_next5(n):
	if n % 5 == 0 or n == 0:
		return n
	else:
		while not n % 5 == 0:
			n += 1
	return n


def round_to_next5(n):
	n = list(range(n, n + 5))
	res = [str(i) for i in n if i % 5 == 0]
	return int(''.join(res))


import math

def round_to_next5(n):
	a = n
	nearest_multiple = 5 * math.ceil(a / 5)
	return nearest_multiple


def round_to_next5(n):
	if n % 5 == 0:
		return n
	else:
		to_add = 5 - n % 5
		return n + to_add


def round_to_next5(n):
	five_rounded = ()
	if n % 5 == 0:
		return n
	elif n % 5 != 0 and n > 0:
		return n + (5 - n % 5)
	else:
		return n + (5 - n % 5)


def round_to_next5(n):
	if n == 0 or n % 5 == 0:
		return n
	else:
		n += 5 - n % 5
		return n


import math

def round_to_next5(n):
	divide = n / 5
	new = math.ceil(divide)
	n = new * 5
	return n


def round_to_next5(n):
	if n == 0 or abs(n) % 5 == 0:
		return n
	else:
		for i in range(6):
			if (n + i) % 5 == 0:
				return n + i


import math

def round_up(n, decimals=0):
	multiplier = 5 ** decimals
	return math.ceil(n * multiplier) / multiplier

def round_to_next5(n):
	m = round_up(n, -1)
	return m


def round_to_next5(n):
	a = n % 5
	if a == 0:
		return n
	if a == 1:
		return n + 4
	if a == 2:
		return n + 3
	if a == 3:
		return n + 2
	if a == 4:
		return n + 1


def round_to_next5(n):
	if n % 5 == 0:
		return n
	for i in range(5):
		if (n + i) % 5 == 0:
			return n + i
	return n


def round_to_next5(n):
	roundup = 5 - n % 5
	if n % 5 == 0:
		return n
	else:
		return n + roundup


def round_to_next5(n):
	if n % 5 != 0:
		a = n // 5
		b = (a + 1) * 5
		return b
	else:
		return n


def round_to_next5(n):
	if n % 10 > 5:
		return n - n % 10 + 10
	elif n % 10 == 5 or n % 10 == 0:
		return n
	else:
		return n + (5 - n % 10)


def round_to_next5(n):
	if n == 0:
		return n
	elif n % 5 == 0:
		return n
	else:
		return n - n % 5 + 5
	return n


def round_to_next5(n):
	if n % 5 == 0:
		return n
	if n % 5 != 0:
		n = n + 4
		if n % 5 != 0:
			n = n - 1
			if n % 5 != 0:
				n = n - 1
				if n % 5 != 0:
					n = n - 1
					if n % 5 != 0:
						n = n - 1
					elif n % 5 == 0:
						return n
				elif n % 5 == 0:
					return n
			elif n % 5 == 0:
				return n
		elif n % 5 == 0:
			return n