def maior_primo( n) :
aux = n
while aux > 2 :
if eh_primo( aux) :
return aux
aux -= 1
return 2
def eh_primo( k) :
i = 2
while i * i <= k:
if k % i == 0 :
return False
i += 1
return True
print( 'Maior primo ate 8: ' + str( maior_primo( 8 ) ) )
print( 'Maior primo ate 7: ' + str( maior_primo( 7 ) ) )
print( 'Maior primo ate 100: ' + str( maior_primo( 100 ) ) )
print( 'Maior primo ate 60: ' + str( maior_primo( 60 ) ) )
print( 'Maior primo ate 61: ' + str( maior_primo( 61 ) ) )
print( 'Maior primo ate 3: ' + str( maior_primo( 3 ) ) )
print( 'Maior primo ate 2: ' + str( maior_primo( 2 ) ) )
print( 'Maior primo ate 1: ' + str( maior_primo( 1 ) ) )
print( 'Maior primo ate 0: ' + str( maior_primo( 0 ) ) )
ZGVmIG1haW9yX3ByaW1vKG4pOgogICAgYXV4ID0gbgogICAgd2hpbGUgYXV4ID4gMjoKICAgICAgICBpZiBlaF9wcmltbyhhdXgpOgogICAgICAgICAgICByZXR1cm4gYXV4CiAgICAgICAgYXV4IC09IDEKICAgIHJldHVybiAyCgpkZWYgZWhfcHJpbW8oayk6CiAgICBpID0gMgogICAgd2hpbGUgaSAqIGkgPD0gazoKICAgICAgICBpZiBrICUgaSA9PSAwOgogICAgICAgICAgICByZXR1cm4gRmFsc2UKICAgICAgICBpICs9IDEKICAgIHJldHVybiBUcnVlCgpwcmludCgnTWFpb3IgcHJpbW8gYXRlIDg6ICcgKyBzdHIobWFpb3JfcHJpbW8oOCkpKQpwcmludCgnTWFpb3IgcHJpbW8gYXRlIDc6ICcgKyBzdHIobWFpb3JfcHJpbW8oNykpKQpwcmludCgnTWFpb3IgcHJpbW8gYXRlIDEwMDogJyArIHN0cihtYWlvcl9wcmltbygxMDApKSkKcHJpbnQoJ01haW9yIHByaW1vIGF0ZSA2MDogJyArIHN0cihtYWlvcl9wcmltbyg2MCkpKQpwcmludCgnTWFpb3IgcHJpbW8gYXRlIDYxOiAnICsgc3RyKG1haW9yX3ByaW1vKDYxKSkpCnByaW50KCdNYWlvciBwcmltbyBhdGUgMzogJyArIHN0cihtYWlvcl9wcmltbygzKSkpCnByaW50KCdNYWlvciBwcmltbyBhdGUgMjogJyArIHN0cihtYWlvcl9wcmltbygyKSkpCnByaW50KCdNYWlvciBwcmltbyBhdGUgMTogJyArIHN0cihtYWlvcl9wcmltbygxKSkpCnByaW50KCdNYWlvciBwcmltbyBhdGUgMDogJyArIHN0cihtYWlvcl9wcmltbygwKSkp