Math One Liners

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

This page is dedicated to showcase small snippets of code that may be useful. These small routines are designed to accomplish tasks involving mathematics. Unless specified, output is in Ans.


Primality of Positive Integerjonbush; lirtosiast

This routine works for 3≤X<106 and returns 0 if X is composite, and 1 if X is prime.
If used in an If statement or place where the true value does not matter, you can remove the 0≠.

min(remainder(X,seq(A,A,2,1+√(X
This code can be modified to be faster if X is already known to be odd.
min(remainder(X,seq(A,A,3,1+√(X),2
The following code is faster for large or even X, and works for all 0≤X<3.99*106.
min(X={2,3,5
If X≥7 and fPart(.5X
min(remainder(X,3+2cumSum(not(binompdf(int(.5√(X)),0

Euler's Totient Function Φ(n)kg583

This routine calculates the value of Euler's Totient Function for any integer X>3.

2+sum(seq(gcd(X,A)=1,A,2,X-2

Number of Factorskg583

This routine calculates the number of factors for any integer X>2. A factor is any integer can divide X with no remainder (including 1 and X).

2+Xmean(seq(not(remainder(X,A),A,2,X-2

.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.