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; 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[] primes = []; for(int p = 2; p < pmax; p ++) if(!isCompound[p]) primes ~= p; debug writeln("primes[0 .. 20]:", primes[0 .. 20]); long[] xs = []; foreach(p; primes){ if(h < p * 2) 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; foreach(p; primes){ foreach(i, y; ys) if(y % p == 0){ answer = y; ys[i] = 1; debug writeln("p:", p, " answer:", answer); } } answer.writeln; }