LipeMachado

Untitled

Aug 24th, 2021
457
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. '''
  3. Código Desenvolvido por Felipe Silva Machado
  4. Verificação refatorada se o número é primo ou não.
  5. Link do GitHub com código mais completo: https://github.com/LipeMachado/refactored-prime-number
  6. '''
  7.  
  8. def numberPrime(num):
  9.     isPrime = True;
  10.     divisoes = 2;
  11.    
  12.     while divisoes < num and isPrime:
  13.         if num % divisoes == 0:
  14.             isPrime = False
  15.         divisoes += 1
  16.    
  17.     if isPrime and num != 1:
  18.         return True
  19.     else:
  20.         return False
  21.    
  22. print("Seu número é primo?")
  23. userNumber = int(input("Digite um número: "))
  24.  
  25. print(numberPrime(userNumber))
Advertisement
Add Comment
Please, Sign In to add comment