Created
December 8, 2020 18:48
-
-
Save Stilic/7ffbbe5b68346d968bc7bde24e726173 to your computer and use it in GitHub Desktop.
a python 3 program for say if thats number is a first number
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
# define the basic variable | |
stop = False | |
# make an function for gets all factors of an number | |
def getFactors(n): | |
# create an empty list for factors | |
factors=[]; | |
# loop over all factors | |
for i in range(1, n + 1): | |
if n % i == 0: | |
factors.append(i) | |
# return the list of factors | |
return factors | |
# make an function for says if a number is a first number | |
def isAFirstNumber(num): | |
if 1 and num in getFactors(num): | |
if len(getFactors(num)) == 2: | |
return str(num) + " is a first number!" | |
else: | |
return str(num) + " is not a first number..." | |
else: | |
return "nope" | |
while stop == False: | |
try: | |
try: | |
intet = int(input("Type a number> ")) | |
except ValueError: | |
print("I DON'T KNOW THIS!!!") | |
continue | |
if intet == "": | |
print("Type really a number, please!") | |
else: | |
print(isAFirstNumber(int(intet))) | |
except KeyboardInterrupt: | |
print("Goodbye!") | |
stop = True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment