Some Programs For the Casio fx-6300g

I bought an old Casio fx-6300g graphing calculator from ebay (it's so tiny!), and couldn't find many programs written for it. Who would imagine that the internet wouldn't be awash in programs for an obscure, low-end calculator from 27 years ago? So, I wrote a few: prime factors, binomial probability, and negative binomial probability.

Prime Factors

This is the typical mod-30 seive. Nothing fancy here. If you don't want to store them as Prog 0 and Prog 1, make sure you update the references to Prog 1 that are present in Prog 0.

Prog 0

```"A"?→A
0→C
2:Prog 1
1:Prog 1
2:Prog 1
2:Prog 1
Lbl 1
A=1⇒Goto 9
C²>A⇒Goto 8
4:Prog 1
2:Prog 1
4:Prog 1
2:Prog 1
4:Prog 1
6:Prog 1
2:Prog 1
6:Prog 1
Goto 1
Lbl 8
A◢
Lbl 9
```

Prog 1

```C+Ans→C
Lbl 0
Frac (A÷C)≠0⇒Goto 1
A÷C→A
C◢
Goto 0
Lbl 1
```

Binomial Probability Distribution

This program calculates a cumulative binomial probability distribution for a number of successes between lower (L) and upper (H) bounds (inclusive). Enter the same value for L and H if you don't want a cumulative result. Enter the number of trials in N, and the probability of success of a single trial in P.

The fx-6300g has no built in nCr (or nPr) functions, so this program first calculates the trivial base case of zero successes (which is just (1-P)N), and recursively calculates f(N, R+1, P), adding to the cumulative total once R≥L, and stopping once R reaches H. (I've used this same method in an HP 41C program, and it's much faster than the naive approach of implementing nCr and calling it repeatedly to calculate the individual probabilities.)

```"N"?→N
"P"?→P
"L"?→L
"H"?→H
(1-P)^N→S
0→R
0→T
Lbl 1
R≥L⇒T+S→T
R≥H⇒Goto 9
S×(N-R)÷(R+1)×P÷(1-P)→S
R+1→R
Goto 1
Lbl 9
T
```

Negative Binomial Probability Distribution

This program will calculate a negative binomial probability distribution, starting with number of trials N equal to the required number of successes R, and increasing N without bound until the program is stopped.

Enter the required number of successes at the "NEED" prompt, enter the probability of a single success into P, and select the display mode. Choosing 1 shows the probability for the Rth success occuring exactly on the Nth trial, 2 shows the cumulative probability for x≤N trials, and 3 shows x≥N trials. Keep pressing EXE to show successive values for N and total probability. Press AC or change modes to stop the program.

Note that the program will also plot cumulative probability for x≤N as you go, so you can set the range accordingly before running the program, then press G↔T afterwards to view the graph. You can omit the single "Plot" instruction if you don't want this behavior.

Like the binomial probability distribution program, this calculates a base case (N=R, which is just PR), and then recursively computes f(N+1, R, P).

```"NEED"?→R
"P"?→P
"1= 2≤ 3≥"?→M
R→N
P^R→E
0→L
Lbl 1
N◢
L+E→L
M=1⇒E◢
M=2⇒L◢
M=3⇒1-L+E◢
Plot N,L
E×N÷(N-R+1)×(1-P)→E
N+1→N
Goto 1
```