[HP35s] Program for prime number (Wheel Sieve and Miller-Rabin)
|
02-14-2019, 08:50 PM
Post: #17
|
|||
|
|||
RE: [HP35s] Program for prime number (brut force)
(02-14-2019 06:26 PM)Albert Chan Wrote: What happens if you do not check each remainder goes to zero, but collect it all per turns ? Here's a program for the HP-42S using this idea: Code: 00 { 120-Byte Prgm } Translation should be straight forward for the HP-35s or pretty much any calculator that supports MOD and register arithmetics. It works only for input > 29 and returns 0 for composite numbers. In this case one of the numbers in registers 00-07 is a factor. Otherwise it returns a number a bit bigger than the input. Examples: 24883 XEQ "PRIME?" y: 24883 x: 0 24883 = 149 × 167 99999999977 XEQ "PRIME?" y: 99999999977 x: 100000780441 99999999977 is a prime. Cheers Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)