(30b) Some number theory progs
|
10-30-2014, 11:05 AM
(This post was last modified: 06-15-2017 01:25 PM by Gene.)
Post: #1
|
|||
|
|||
(30b) Some number theory progs
Finds smallest factor of odd integer input. Returns input & factor or 0 if prime.
0 P0 1 Lbl 02 2 STO 0 3 √ 4 Math 5 Up 6 Up 7 Input 8 STO 2 9 3 10 STO 1 11 Lbl 00 12 RCL 0 13 RCL 1 14 / 15 Math 16 Up 17 Input 18 GT 01 19 RCL 0 20 RCL 1 21 RTN 22 Lbl 01 23 2 24 STO+ 1 25 RCL 1 26 RCL 2 27 ?≤ 28 GT 00 29 RCL 0 30 0 31 = 32 RTN Finds next prime after input integer 0 P1 1 Lbl 04 2 STO 0 3 2 4 / 5 Math 6 Up 7 Input 8 GT 03 9 1 10 STO- 0 11 Lbl 03 12 2 13 STO+ 0 14 RCL 0 15 Call02 16 GT 03 17 RCL 0 18 RTN Returns an input-digit random integer, max digits 12 0 P2 1 Lbl 05 2 Input 3 1 4 2 5 Input 6 ?< 7 GF 06 8 R↓ 9 Lbl 06 10 1 11 0 12 Swap 13 Y^X 14 Rand 15 * 16 Math 17 Up 18 Up 19 Input 20 RTN Returns an input-digit random prime 0 P3 1 Lbl 07 2 Call05 3 Call04 4 RTN Returns a 2*input-digit semi-prime 0 P4 1 STO 3 2 Call07 3 STO 4 4 RCL 3 5 Call07 6 RCL 4 7 * 8 RTN Returns approx number of primes less than input 0 P5 1 Input 2 Input 3 Input 4 Ln 5 1 6 - 7 / 8 Math 9 Up 10 Up 11 Input 12 RTN I'm sure these progs are not optimized, I haven't really got the hang of programming on the 30b & would be pleased for optimization suggestions. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(30b) Some number theory progs - Gerald H - 10-30-2014 11:05 AM
|
User(s) browsing this thread: 1 Guest(s)