Last active
January 24, 2020 19:27
-
-
Save les-peters/b6ea75ced2a1bdeede8944c5295655f9 to your computer and use it in GitHub Desktop.
Cassidoo IQofW 2020-01-20
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
import math | |
primeFactors = [] | |
def factorPrecheck(factor): | |
for primeFactor in primeFactors: | |
if factor % primeFactor == 0: | |
return False | |
return True | |
def isFactorial(number): | |
for factorTest in range(2, int(math.sqrt(number)) + 1): | |
# I added this to only test against primes, but it makes the code slower | |
# if factorPrecheck(factorTest): | |
if number % factorTest == 0: | |
return True | |
else: | |
primeFactors.append(factorTest) | |
return False | |
print(isFactorial(3)) | |
print(isFactorial(6)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment