Educational+Resources+-+Math

Math Snippets
Why reinvent the wheel? These snippets are freely shared for math educators to use within their Just BASIC programs. If you have a reliable snippet for math functions, please consider sharing. toc


 * Basic Math Functions
 * //Finding Least Common Multiple//**

//**How to draw a circle with 2 different functions**//
 * Geometry Functions
 * //Finding the Area of a Rectangle//**



Basic Math
Basic Math functions include snippets for Addition, Subtraction, Multiplication, Division, Fractions, Decimals, etc.

 Snippet using a Gosub code format="vbnet" n1 = 8 n2 = 6 Print n1, n2   Gosub [LCM]
 * //Finding the Least Common Multiple//**

Print "LCM = ";LCM

End

[LCM] For i = n1 * n2 to 2 Step -1 If i Mod n1 = 0 Then If i Mod n2 = 0 Then LCM = i           End If        End If    Next i Return code Snippet using a Function code format="vbnet" n1 = 4 n2 = 6 Print n1, n2 Print "LCM = ";LCM(n1, n2)

End

Function LCM(n1, n2) For i = n1 * n2 to 2 Step -1 If i Mod n1 = 0 Then If i Mod n2 = 0 Then LCM = i           End If        End If    Next i End Function code