Skip to content

Instantly share code, notes, and snippets.

@mistrikushal
Last active January 26, 2016 14:43
Show Gist options
  • Save mistrikushal/09b4929860422183118a to your computer and use it in GitHub Desktop.
Save mistrikushal/09b4929860422183118a to your computer and use it in GitHub Desktop.
multiply 2 numbers without X operator
# perform multiplication on 'a' and 'b' without using X operator
def mul(a, b)
x = 0
b.times do
x = x + a
end
puts "Multiplication of #{a.to_s} X #{b.to_s} = #{x.to_s}"
end
mul(4, 4)
# output 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment