import std.stdio, std.conv, std.string, std.bigint; import std.math, std.random, std.datetime; import std.array, std.range, std.algorithm, std.container; string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; } void main(){ long l = read.to!long; long h = read.to!long; int pmax = 100_000; // if(h < 10_000) pmax = 100; debug writeln("pmax:", pmax); bool[] isCompound = new bool[](pmax); for(int i = 2; i < pmax; i ++){ if(isCompound[i]) continue; for(int j = i + i; j < pmax; j += i){ isCompound[j] = 1; } } debug writeln("isCompound[0 .. 20]:", isCompound[0 .. 20]); long[] xs = []; for(int p = 2; p < pmax; p ++){ if(isCompound[p]) continue; if(p >= l) break; if(l <= (h / p) * p) xs ~= (h / p) * p; } xs.sort(); debug writeln("xs:", xs); long[] ys; { long y = 0; foreach(x; xs) if(x != y) y = x, ys ~= y; } debug writeln("ys:", ys); long answer = 0; for(int p = 2; p < pmax; p ++){ if(isCompound[p]) continue; foreach(i, y; ys) if(y % p == 0){ answer = y; ys[i] = 1; debug writeln("p:", p, " answer:", answer); } } answer.writeln; }