Skip to content

Instantly share code, notes, and snippets.

@rscarvalho
Created March 17, 2018 09:51
Show Gist options
  • Save rscarvalho/3c4a49f5b80bcc8f53ac5fd673aab2d2 to your computer and use it in GitHub Desktop.
Save rscarvalho/3c4a49f5b80bcc8f53ac5fd673aab2d2 to your computer and use it in GitHub Desktop.
def eh_primo(x):
fator = 2
while x % fator != 0 and fator <= x / 2:
fator = fator + 1
if x % fator == 0:
return False
else:
return True
def maio_primo(n):
maior_numero = 0
i = 2
while i <= n:
if eh_primo(i):
print(i)
maior_numero = i
i = i + 1
return maior_numero
n = int(input('Digite um número: '))
print('Maior numero primo: ' + str(maior_primo(n))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment