Talk:Minimum positive multiple in base 10 using only 0 and 1

Revision as of 17:00, 1 March 2020 by rosettacode>Horst.h (→‎need for speed: new section)

something's wrong

In the task's preamble   (in the E.G. section),   the 4th multiplication   (for a   B10   of   111,111,111),   the multiplier is incorrect.   The multiplier shown would yield a   B10   value of   1,111,111,101,   which isn't the minimum   B10   for a   N   of   9.     -- Gerard Schildberger (talk) 18:57, 29 February 2020 (UTC)

Hi Gerard, you multiply 'n' by the multiplier so 9 x 12,345,679 = 111,111,111 --PureFox (talk) 19:19, 29 February 2020 (UTC)
That's all well and good.   But, the example that I was talking about shows that   9 ×  123,456,789   which is the number shown in the task's preamble,   not  9 × 12,345,679.     -- Gerard Schildberger (talk) 19:32, 29 February 2020 (UTC)
Yes, it was wrong originally but it's correct now. --PureFox (talk) 19:41, 29 February 2020 (UTC)
Ah, it looks like an '8' has crept into the multiplier - I'll remove it. --PureFox (talk) 19:25, 29 February 2020 (UTC)
But,   "it"   could've been an incorrect   B10,   where the   B10   coulda/shoulda/woulda have been   1,111,111,101,   which would make the original multiplier correct.   I could've corrected either value, but one does not want to be accused of vandalism (again).     -- Gerard Schildberger (talk) 19:49, 29 February 2020 (UTC)
True, but four of us now have come up now with a multiplier of 12,345,679 for n = 9 and the OEIS reference shows a B10 figure of 111,111,111 for that value of 'n', so I'm as sure as I can be that everything is now in order.--PureFox (talk) 20:00, 29 February 2020 (UTC)

need for speed

in my Pascal version I use modular arithmetic. First I create a list of all B10 upto 19 Digits, thats only Limit = 2^19= 524288 values.
While searching for Low Value aka LV =B10(i). LV MOD N == 0 I memorize (LV MOD N) and the position of the first occurence of (LV MOD N)
This list has the indices 0 to N-1, preset with -1, and the i of B10(i) is inserted at (LV MOD N) When I found a value I am finished and go to output.
Else I start with a High Value HV =B10(j) | j =1..Limit.This HV is shifted by 10^19, but only modular
so (HV*10^19) MOD N <=> ((HV MOD N)*(10^19 MOD N) MOD N
(HV MOD N) is alredy calculated,(10^19 MOD N) once for N
To generate the new number (HV+LV ) MOD N I only have to add (HV mod N) + (LV mod N) the result = 0.. 2*n-2.
But only (HV mod N) + (LV mod N) = N is equal to ((HV mod N) + (LV mod N)) MOD N = 0, what is the search for.
Now I am only check if (N-(HV mod N)) is in the list of first occurence.
The values upto 9998 are the same as in OEIS:oeis.org/A004290/b004290.txt
There are only 98 values upto 1E6, which are out of range.But first I have to set ModToIdx  : array[0..1000000] of Int32
--Horst.h 17:00, 1 March 2020 (UTC)~

Return to "Minimum positive multiple in base 10 using only 0 and 1" page.