Casio fx-3800P "Programming"
|
03-06-2020, 02:42 PM
Post: #1
|
|||
|
|||
Casio fx-3800P "Programming"
I use the word "programming" a bit loosely, because this model does little more than record a sequence of keystrokes, with a placeholder (ENT) to pause and get user input. It has somewhere around 150 program steps that can be split up across 4 programs, but programs can't call each other. This is literally the full extent of the flow control and decision making:
- Pause and display a result (HLT) - Pause the program and accept an input (ENT) - Restart the program (RTN) - Restart the program if x>0 - Restart the program if x<=M No labels, no goto. Despite this, the manual has a few clever sample programs, like this one that simulates indirect addressing to accumulate frequency sums for a five-bucket histogram: Code: Prog I Initialize the program by pressing Shift KAC, then I. Input the bucket number (1-5) and press RUN, then input the value/frequency and press RUN. Keep entering bucket number and frequency pairs, and press II to view the totals (press RUN to view the next total). Arguably, one could simply use K in + n to accumulate the values, but the program saves one keystroke per data pair, and you don't risk destroying a total if you miss the + key. You wouldn't think it would be possible to write a prime factor finder on a calculator with no Int or Frac functions, and no flow control besides "once more from the top", but fortunately I have more determination than sense, so here it is. The program needs all 7 storage registers and uses Fix 0 mode and the Rnd function to round division results, which is just enough to test divisibility. It can factor 9,999,999,999 in about a minute. There is definitely no mod 30 sieve here. Code: Prog I To use the program, enter the number to factor and press I. Then press II to start factoring. The program will stop when it finds a factor. Press RUN to find the next factor. The program will deliberately cause an error to end early once the divisor has exceeded the square root of the remaining numerator (it does this by attempting to take the square root of the numerator's square root minus the divisor - just pretend the "E" stands for End). Press AC, K out 1 to see the final factor. The program can accurately factor any integer up to the full 10-digit precision of the calculator, if you're patient enough. (e.g. it doesn't think 2 is a factor of 9,999,999,999.) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)