HP 49G: Minimum Multiplier M of Integer N such that M*N Consists Only of 1's & 0's
|
01-28-2020, 12:13 AM
(This post was last modified: 02-01-2020 10:55 PM by Albert Chan.)
Post: #11
|
|||
|
|||
RE: HP 49G: Minimum Multiplier M of Integer N such that M*N Consists Only of 1's &...
(01-27-2020 04:11 PM)Albert Chan Wrote: For my old Pentium 3, time for p(n = 0 to 9999) in 21 seconds (4 seconds for my laptop) To take advantage of Python's O(1) dictionary lookup, here is p(n) dict() based version. Timings for p(n = 0 to 9999) reduced to Pentium3 = 8.1 s., Laptop = 1.5 s. (≈ 2.5X speed) Code: hd = [0,1,10,11,100,101,110,111] Update: new algorithm, odd p = 10m+1, solve for m ≡ -1/10 (mod n), return 10m+1 Timings for p(n = 0 to 9999) improved to Pentium3 = 4.8 s., Laptop = 0.9 s. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)