To find the surface area of a regular polygon inscribed in a sphere, we need to find the area of each face of the polygon and then add them up.
Here's the code in Ruby using the Math module:
main.rb503 chars19 linesTo use this function, simply call it with the number of sides of the polygon (n) and the radius of the sphere (r) as arguments:
main.rb243 chars6 linesOutput:
main.rb98 chars2 lines
gistlibby LogSnag