Skip to content

Instantly share code, notes, and snippets.

@SebAshton
Created August 1, 2014 17:16
Show Gist options
  • Save SebAshton/d258bbae7f40fa0132ba to your computer and use it in GitHub Desktop.
Save SebAshton/d258bbae7f40fa0132ba to your computer and use it in GitHub Desktop.
round number to the nearest 5 or 9
def round_price(price)
amount = price.ceil()
if amount % 10 < 5
amount = amount + 5 - (amount % 5)
else
amount = amount + 9 - (amount % 9)
end
amount
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment