brewersfan1976

quadratic_equation.rb

Jun 12th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.33 KB | None | 0 0
  1. def quadraticEquation(a, b, c)
  2.     x = -50.0
  3.     output_array = Array.new
  4.     y = 0
  5.    
  6.     while (x <= 50)
  7.           if a * x ** 2 + b * x + c == 0 then
  8.              output_array[y] = x.to_f
  9.              y = y + 1
  10.           end
  11.              
  12.           x = x + 0.5
  13.     end
  14.        
  15.     return output_array.sort
  16. end
Advertisement
Add Comment
Please, Sign In to add comment