Created
March 17, 2018 09:51
-
-
Save rscarvalho/3c4a49f5b80bcc8f53ac5fd673aab2d2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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