Skip to content

Instantly share code, notes, and snippets.

@gerep
Created August 31, 2017 02:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gerep/fb0562de21d5a40bd20cf2f760217b8e to your computer and use it in GitHub Desktop.
Save gerep/fb0562de21d5a40bd20cf2f760217b8e to your computer and use it in GitHub Desktop.
def maior_primo(n):
cont = 1
maior = 0
while cont <= n:
if primo(cont):
if cont > maior:
maior = cont
cont += 1
return maior
def primo(n):
if n == 2:
return True
if not n & 1:
return False
for x in range(3, int(n**0.5)+1, 2):
if n % x == 0:
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment