from math import floor, sqrt

def prime(n):
	if (n & 1):
		n -= 2
	else:
		n -= 1
	
	i,j = 0,3

	for i in range(n, 2, -2):
		if i % 2 == 0:
			continue

		while j <= floor(sqrt(i)) + 1:
			if i % j == 0:
				break
			j += 2

		if (j > floor(sqrt(i))):
			return i

	return 2

print(prime(int(input())))

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: