We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 08d8c6b commit 0121c89Copy full SHA for 0121c89
Maths/SurfaceAreaOfTorus.js
@@ -0,0 +1,18 @@
1
+/**
2
+ * Surface Area of a Torus
3
+ * Reference: https://en.wikipedia.org/wiki/Torus
4
+ *
5
+ * Formula:
6
+ * A = 4 * π² * R * r
7
8
+ * @param {number} majorRadius - Distance from the center of the tube to the center of the torus (R)
9
+ * @param {number} minorRadius - Radius of the tube (r)
10
+ * @returns {number} Surface area of the torus
11
+ */
12
+export function surfaceAreaOfTorus(majorRadius, minorRadius) {
13
+ if (majorRadius < 0 || minorRadius < 0) {
14
+ throw new Error("Radii must be non-negative");
15
+ }
16
+
17
+ return 4 * Math.PI ** 2 * majorRadius * minorRadius;
18
+}
0 commit comments