Hp Algorithm to create random numbers
|
08-26-2024, 11:21 AM
Post: #20
|
|||
|
|||
RE: Hp Algorithm to create random numbers
(08-25-2024 02:50 PM)Albert Chan Wrote: state * 2851130928467 ≡ 163041130928467 (mod 10^15) Faster way to solve, scale to reduce multiplier to 1, 2nd column is state. Cas> m := 10^15 Cas> [2851130928467, 163041130928467] * 3; /* force multiplier last digit = 1 */ [8553392785401,489123392785401] Cas> (Ans*(2-Ans[1])) MOD m [667229546840001,469799546840001] [246014400000001,248584400000001] [1,2570000000001] --> state = 002570000000001 This trick work for other modulus too. Also, MOD can be signed mod Example: solve 7x ≡ 9 (mod 3^5) Base 3, last digit 7%3 = 1, we keep scaling to zeroed out other digits. Cas> [7, 9] %% 3^5 Cas> Ans*(2-Ans[1]) [-35 %% 243,-45 %% 243] [-80 %% 243,36 %% 243] [1 %% 243,36 %% 243] --> x ≡ 9/7 ≡ 36 (mod 3^5) |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)