Post Reply 
scramble prime challenge
02-16-2020, 02:19 PM
Post: #17
RE: scramble prime challenge
(02-15-2020 11:11 PM)Allen Wrote:  I think it can be cut down to 57-59 without too much effort..
Don, thanks for an interesting challenge! Using some random trials to pack the primes into fewer registers try to minimize the number of bytes used as sum(length(numbers)+number of registers)

Code:

00 { 56-Byte Prgm }
01 STO 01
02 3446782235
03 RCL 01
04 MOD
05 7592533501
06 RCL 01
07 MOD
08 ×
09 8332054977
10 RCL 01
11 MOD
12 ×
13 8199551426
14 RCL 01
15 MOD
16 ×
17 .END.

I looked at using primitive roots and indices to see if there was a cheaper way to store set membership, but since several of these primes are under 20, there is no primitive root product that has a smaller product than just these primes.

For example, \( 7^p \mod 997 \) is a primitive root with a unique index for all of these primes \(p \), but you get [49, 343, 855, 21, 571, 63, 716, 704, 118, 433, 280, 840, 746, 818, 152, 936, 278, 700, 833, 601, 241, 667] rather than the original list.. which has no numbers under 20. (plus there is a minor annoyance that none of the HP calculators I know of have modular exponentiation.. maybe the prime does?)

Our hand held could not calculate \( 7^{991} =91706260460847671 \ldots 772735017410743 \)
(883 decimal digits )
but with a small program could easily calculate

\( 7^{991} \mod 997 = 667 \)

Modular exponential on HP 42S (free42 program)
enter base,exponent, modulus then XEQ PMOD
returns \( b ^ x \mod m\) on ST X


Code:

00 { 40-Byte Prgm }
01>LBL "PMOD"
02 STO 03
03 SIGN
04 X<>Y
05>LBL 01
06 STO 02
07 1
08 AND
09 RCL× ST Z
10 X=0?
11 SIGN
12 ×
13 RCL 03
14 MOD
15>LBL 02
16 X<>Y
17 X^2
18 RCL 03
19 MOD
20 X<>Y
21 RCL 02
22 2
23 BASE÷
24 X!=0?
25 GTO 01
26 Rv
27 END

17bii | 32s | 32sii | 41c | 41cv | 41cx | 42s | 48g | 48g+ | 48gx | 50g | 30b

Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
scramble prime challenge - Don Shepherd - 02-14-2020, 01:14 AM
RE: scramble prime challenge - Paul Dale - 02-14-2020, 03:02 AM
RE: scramble prime challenge - Albert Chan - 02-14-2020, 04:39 AM
RE: scramble prime challenge - Albert Chan - 02-14-2020, 04:02 PM
RE: scramble prime challenge - Paul Dale - 02-14-2020, 04:43 AM
RE: scramble prime challenge - ttw - 02-14-2020, 01:56 PM
RE: scramble prime challenge - John Keith - 02-14-2020, 10:09 PM
RE: scramble prime challenge - John Keith - 02-15-2020, 06:59 PM
RE: scramble prime challenge - John Keith - 02-16-2020, 07:11 PM
RE: scramble prime challenge - Albert Chan - 02-15-2020, 02:14 PM
RE: scramble prime challenge - Albert Chan - 02-17-2020, 06:23 PM
RE: scramble prime challenge - Albert Chan - 02-19-2020, 12:16 AM
RE: scramble prime challenge - Allen - 02-15-2020, 11:11 PM
RE: scramble prime challenge - Allen - 02-16-2020 02:19 PM



User(s) browsing this thread: