repl.it
@bbenefield89/

Round Nearest Whole N

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
def roundToNearest(x, y):
  rounded = round(x / y) * y
  if rounded == 0:
    return y
  else:
    return rounded


def roundNearest(x, y):
  return 0 if round(x / y) * y == 0 else round(x / y) * y


print(roundToNearest(150, 50))
print(roundNearest(150, 50))
?