Lowest price ever! Learn Generative AI for 48% less!
Get my discount0
Square root in Ruby
How could I calculate the square root in Ruby? I've tried sqrt() and math.sqrt(), but none of them worked.
2 Answers
+ 9
You have to import CMath library .
for example:-
require 'cmath'
x = CMath.sqrt(5)
puts x
+ 2
I just figured it out: I have to write Math.sqrt, in high case. Thanks, guys.