brewersfan1976

magical_well.rb

May 28th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.26 KB | None | 0 0
  1. def magicalWell(a, b, n)
  2.     x = 1
  3.     sum = 0
  4.     a_value = a
  5.     b_value = b
  6.    
  7.     while (x <= n)
  8.         sum = sum + (a_value * b_value)
  9.         a_value = a_value + 1
  10.         b_value = b_value + 1
  11.         x = x + 1
  12.     end
  13.    
  14.     return sum
  15. end
Add Comment
Please, Sign In to add comment