WARNING: Beer soaked rambling/opinion/observation ahead. Read at your own risk. Not to be taken seriously. In no event shall Sir jonah in his inebriated state be liable to anyone for special, collateral, incidental, or consequential damages in connection with or arising out of the use of his beer (and tequila) powered views.

The subforum description says "For all calculator topics".including programming

Here it goes:

Viviani's theorem, named after Vincenzo Viviani, states that the sum of the distances from any interior point to the sides of an equilateral triangle equals the length of the triangle's altitude.

Came across this beauty a while back from a book and became fascinated with it. Authors suggested to students to check out theorem using good old fashioned ruler. Thought I should supplement that suggestion with a program. Maybe some high school kids can have some fun with it. Just wondering if BASIC is still in use these days though.

1 REM THIS PROGRAM WILL SHOW THAT THE SUM OF THE PERPENDICULAR DISTANCES

2 REM FROM AN INTERIOR POINT G OF ANY EQUILATERAL TRIANGLE ABC WITH SIDE

3 REM LENGTH OF S IS THE SAME NO MATTER WHICH POINT IS CHOSEN. THIS SUM

4 REM IS = TO THE ALTITUDE OF AN EQUILATERAL TRIANGLE.

5 REM THE EQUILATERAL TRIANGLE IS POSITIONED ON THE CARTESIAN COORDINATE

6 REM SYSTEM SO THAT VERTEX A IS AT THE ORIGIN AND SEGMENT AB IS ON THE

7 REM X-AXIS. VERTEX B IS THEN AT (S,0) AND VERTEX C IS AT

8 REM [.5*S, .5*SQR(3)*S]. POINT G(X,Y) IS ANY POINT IN THE INTERIOR OF

9 REM TRIANGLE ABC. IN ADDITION, E(X,0) IS A POINT ON THE X-AXIS SO THAT

10 REM IT IS BETWEEN THE ORIGIN AND VERTEX B, AND SUCH THAT SEGMENT GE IS

11 REM PERPENDICULAR TO SEGMENT AB; D IS A POINT ON SEGMENT AC SO THAT

12 REM IT IS BETWEEN THE ORIGIN AND VERTEX C, AND SUCH THAT SEGMENT GD

13 REM IS PERPENDICULAR TO SEGMENT AC; F IS A POINT ON SEGMENT CB SO

14 REM THAT IT IS BETWEEN VERTEX C AND VERTEX B, AND SUCH THAT SEGMENT

15 REM GF IS PERPENDICULAR TO SEGMENT CB. ACCORDINGLY, THE ALTITUDE OF

16 REM AN EQUILATERAL TRIANGLE WITH SIDE LENGTH OF S IS GIVEN BY

17 REM .5 * SQR(3) * S, WHICH IS ALSO THE Y COORDINATE OF VERTEX C.

30 INPUT "ENTER THE LENGTH S OF EQUILATERAL TRIANGLE ABC WHERE S IS > 0 "; S

40 IF S > 0 THEN 53

50 IF S <= 0 THEN 51

51 PRINT "S MUST BE > 0. TRY AGAIN."

52 GOTO 30

53 PRINT "WITH S = "; S; ", X'S DOMAIN (OR INTERIOR X COORDINATE) MUST BE 0 < X < "; S; ""

60 INPUT "ENTER THE INTERIOR X COORDINATE"; X

70 IF X > 0 THEN 90

80 IF X <= 0 THEN 81

81 PRINT "X MUST BE > 0. TRY AGAIN."

82 GOTO 60

90 IF X <= (.5 * S) THEN 110

100 IF X > (.5 * S) THEN 200

110 LET A = X * SQR(3)

120 PRINT "WITH X = "; X; ", Y'S RANGE (OR INTERIOR Y COORDINATE) MUST BE 0 < Y < "; A; ""

130 INPUT "ENTER THE INTERIOR Y COORDINATE"; Y

140 IF Y > 0 THEN 160

150 IF Y <= 0 THEN 151

151 PRINT "Y MUST BE > 0. TRY AGAIN."

152 GOTO 130

160 IF Y < A THEN 390

170 IF Y >= A THEN 171

171 PRINT "Y MUST BE < "; A; ". TRY AGAIN."

172 GOTO 130

200 IF X < S THEN 220

210 IF X >= S THEN 211

211 PRINT "Y MUST BE < "; S; ". TRY AGAIN."

212 GOTO 60

220 LET B = (-1) * SQR(3) * X + SQR(3) * S

230 PRINT "WITH X = "; X; ", Y'S RANGE (OR INTERIOR Y COORDINATE) MUST BE 0 < Y < "; B; ""

240 INPUT "ENTER THE INTERIOR Y COORDINATE"; Y

250 IF Y > 0 THEN 270

260 IF Y <= 0 THEN 261

261 PRINT "Y MUST BE > 0. TRY AGAIN."

262 GOTO 240

270 IF Y < B THEN 390

280 IF Y >= B THEN 281

281 PRINT "Y MUST BE < "; B; ". TRY AGAIN."

282 GOTO 240

390 LET H = .5 * SQR(3) * S

400 LET Q = X / 4 + SQR(3) * Y / 4

410 LET R = (-1) * SQR(3) * Q / 3 + SQR(3) * X / 3 + Y

420 LET V = 3 * S / 4 + X / 4 - Y * SQR(3) / 4

430 LET W = SQR(3) * V / 3 - SQR(3) * X / 3 + Y

440 LET K = SQR((X - Q) ^ 2 + (Y - R) ^ 2)

450 LET L = SQR((X - V) ^ 2 + (Y - W) ^ 2)

460 LET Z = Y + K + L

461 PRINT "WITH POINT G AT ("; X; ","; Y; ")"

462 PRINT "POINT E IS AT ("; X; ",0), AND"

463 PRINT "POINT D IS AT ("; Q; ","; R; "), AND"

464 PRINT "POINT F IS AT ("; V; ","; W; ")"

465 PRINT "WE THEN HAVE"

466 PRINT "EG = SQR [ ("; X; " - "; X; ") ^ 2 + ("; Y; " - 0 ) ^ 2 ] = "; Y; ""

467 PRINT "DG = SQR [ ("; X; " - "; Q; ") ^ 2 + ("; Y; " - "; R; ") ^ 2 ] = "; K; ""

468 PRINT "FG = SQR [ ("; X; " - "; V; ") ^ 2 + ("; Y; " - "; W; ") ^ 2 ] = "; L; ""

499 PRINT "THUS,"

500 PRINT "THE SUM OF PERPENDICULAR DISTANCES FROM AN INTERIOR POINT OF AN EQUILATERAL"

501 PRINT "TRIANGLE WITH SIDE LENGTH OF "; S; " IS"

510 PRINT "EG + DG + FG = "; Y; " + "; K; " + "; L; " = " ; Z; ""

520 PRINT "THE ALTITUDE OF AN EQUILATERAL TRIANGLE WITH SIDE LENGTH OF "; S; " IS"

521 PRINT ".5 * SQR(3) * "; S; " = "; H; ""

530 END