Many math students have to use the same formulas over and over again. This article is going to show you how to build a script to do one formula and then how to add more and more.

## Slope ScriptEdit

In math class, we all learned the following formula:

$ Slope = \frac{Y_2 - Y_1}{X_2 - X_1} $

Since we are creating a script to solve for an unknown value, we need to ask the user to input the values needed to solve for the unknown. In this case, we need the user to input X_{1}, Y_{1}, X_{2}, and Y_{2}. After the user has given those values, the value of the unknown needs to be displayed.

Now that you know exactly what you need to do, try writing the script by yourself. If you get stuck or want to check your work, the source code can be found here.

## Distance ScriptEdit

Another common formula in math is the distance formula:

$ Distance = \sqrt{(X_2 - X_1)^2 + (Y_2 - Y_1)^2} $

As with the slope script, we as the programmers don't know the coordinates. We need some input from the user so we can use the formula. Try writing the script and if you get stuck, you can find the source code here.

## Interior Angles of a PolygonEdit

### Sum of the Interior Angles of PolygonEdit

One thing that is a common occurrence in Geometry is finding the sum of the interior angles present in a polygon. This can be done in a simple formula:

$ \text {Sum of interior angles} = 180(n - 2) $

Where *n* is the number of sides. As you can see, this is fairly simple and only requires a few calculations. This is a nice script for novices to try and write by themselves. If you get stuck, an example of a script can be found here.

### Interior Angle of a Regular PolygonEdit

As a variation of the above, you can find the measure of each individual angle in a regular (ie. each side is congruent) polygon. The formula is below:

$ \text {Interior angle of a regular polygon} = \frac{180(n - 2)}{n} $

Where again, *n* is the amount of sides. The source code for this is just a slight variation of this one, but you can find it here