Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A little division script for Discrete Math.
a = ARGV[0].to_i
d = ARGV[1].to_i
begin
raise '`a` (first argument) must be a non-negative integer' unless a >= 0
raise '`d` (second argument) must be a positive integer' unless d > 0
rescue Exception => e
puts "Error: #{e.message}"
Process.exit
end
r = a
q = 0
counter = 0
puts "\n"
loop do
puts "Counter: #{counter}; r: #{r}; q: #{q}"
break if r < d
r -= d
q += 1
counter += 1
end
puts "\nInput: a: #{a}; d: #{d}"
puts "Output: q: #{q}; r: #{r}\n\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.