A317636 Minimum number of consecutive positive integers starting with 1 that must be concatenated in descending order so that n divides the concatenation, or zero if n divides no such concatenation.
1, 0, 2, 0, 0, 0, 2, 0, 8, 0, 14, 0, 15, 0, 0, 0, 9, 0, 5, 0, 2, 0, 16, 0, 0, 0, 26, 0, 4, 0, 25, 0, 14, 0, 0, 0, 21, 0, 15, 0, 40, 0, 67, 0, 0, 0, 78, 0, 54, 0, 9, 0, 66, 0, 0, 0, 5, 0, 25, 0, 111, 0, 44, 0, 0, 0, 161, 0, 18, 0, 49, 0, 30, 0, 0, 0, 73, 0, 15, 0, 27, 0, 27, 0, 0, 0, 41, 0, 20, 0, 54, 0, 47, 0, 0, 0, 63, 0, 18, 0, 98, 0, 102, 0, 0, 0, 3, 0, 99, 0, 21
Offset: 1
Examples
For n=19 the a(19)=5 since 54321 = 19*2859, while 4321, 321, 21 and 1 are not multiples of 19.
Programs
-
Mathematica
Table[If[GCD[n, 10] == 1, Block[{k = 1}, While[Mod[FromDigits@ Flatten@ Map[IntegerDigits, Range[k, 1, -1]], n] != 0, k++]; k],0], {n, 111}] (* Michael De Vlieger, Aug 02 2018 *)
-
PARI
a(n) = {if ((n%2) && (n%5), my(s = ""); for (k=1, oo, s = concat(Str(k), s); if (!(eval(s) % n), return (k)););); return (0);} \\ Michel Marcus, Aug 02 2018
-
Pascal
program skaitlirinda2; var i : longint; function Atrodi(n : longint) : int64; var sk, koefa, naksk, rez : int64; begin sk := 1; naksk := 10; koefa := naksk mod n; rez := sk mod n; while rez>0 do begin Inc(sk); rez := (sk * koefa + rez) mod n; if sk=naksk then naksk := naksk * 10; koefa := (koefa*naksk) mod n; end; Atrodi := sk; end; begin for i:=1 to 10000 do begin if (i mod 2)*(i mod 5) > 0 then writeln(i,' ',Atrodi(i)) else writeln(i,' 0'); end; end.
Comments