# coding: utf-8 from collections import defaultdict as dd from collections import Counter from collections import deque from string import ascii_lowercase import math import array def main(): L,H = map(int,raw_input().split()) root_H = math.sqrt(H) primes = sieve_of_eratosthenes(int(math.ceil(root_H))) square_primes = [x**2 for x in primes] print(primes) cands = [p for p in primes if L <= p**2 <= H] if cands: P = max(cands) flag = True; n = H while flag: for p in primes: if n%p == 0 and n!= p: print(n) flag = False break n -= 1 else: min_factor = 1 retval = 1 for n in range(L,H+1): for p in primes: if n%p == 0 and n != p: if p >= min_factor: min_factor = p retval = n break print(retval) def sieve_of_eratosthenes(end, typecode="L"): assert end > 1 # 整数iが素数であるかをis_prime[i]が示す # 最初はすべてTrueで初期化しておく # 最終的にprimesではなくこれを返してもよい is_prime = array.array("B", (True for i in range(end))) # 0, 1はいずれも素数ではない is_prime[0] = False is_prime[1] = False # 素数を格納する配列 primes = array.array(typecode) # 篩う for i in range(2, end): if is_prime[i]: # iが素数であるとき primes.append(i) # 素数の配列に加える for j in range(2 * i, end, i): # iを超えるiの倍数について is_prime[j] = False # 素数ではないため除外する return primes if __name__ == "__main__": main()