|
Versions Of This Snippet::
Download a raw-text version of this code by clicking on "Download Version"
Latest Snippet Version: :1.0.0.0.0.0.1
print "Enter A value: "
d = gets
a = d.to_i
print "Enter B value: "
e = gets
b = e.to_i
print "Enter C value: "
f = gets
c = f.to_i
derivitive = b*b - 4*a*c
step1 = b*b + Math.sqrt(derivitive)
step2 = b*b - Math.sqrt(derivitive)
step3 = step1 / 2*a
step4 = step2 / 2*a
if derivitive == 0
print "Number of Roots: 1\nRoot: #{step3}"
elsif derivitive > 0
print "Number of Roots: 2\nRoot 1: #{step3} Root 2 #{step4}"
else
print "No roots"
end
Submit a new versionYou can submit a new version of this snippet if you have modified it and you feel it is appropriate to share with others..
|
||||||||||||||||||||||||||
