Skip to content

Instantly share code, notes, and snippets.

@hachy
Created November 11, 2023 00:56
Show Gist options
  • Save hachy/c5a5d0918b1037a285dbf7493384f874 to your computer and use it in GitHub Desktop.
Save hachy/c5a5d0918b1037a285dbf7493384f874 to your computer and use it in GitHub Desktop.
Display prices within a 10% to -10% range of the original price.
v = 1234
10.downto(-10) do |i|
print (v * (1 + (i * 0.01))).round
puts "#{i}%".rjust(5)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment