From d71fa6f60a0797100b3e151ea7f93d8f0b428423 Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Wed, 15 Jun 2022 18:59:58 +0100 Subject: - Added guest contributions by Eric Cheung. --- challenge-169/eric-cheung/python/ch-1.py | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 challenge-169/eric-cheung/python/ch-1.py (limited to 'challenge-169/eric-cheung/python/ch-1.py') diff --git a/challenge-169/eric-cheung/python/ch-1.py b/challenge-169/eric-cheung/python/ch-1.py new file mode 100755 index 0000000000..aa1dde99b9 --- /dev/null +++ b/challenge-169/eric-cheung/python/ch-1.py @@ -0,0 +1,46 @@ + +## Remarks + +import math + +def PrimeFact(nInput): + + for nDiv in range(2, int(math.sqrt(nInput)) + 1): + if nInput % nDiv == 0: + return nDiv + + return 0 + + +def IsBrillNum(nInput): + + nFact = PrimeFact(nInput) + + if nFact == 0: + return False + + nFact_2 = int(nInput / nFact) + + nNum = PrimeFact(nFact_2) + + if nNum > 0: + return False + + if len(str(nFact)) == len(str(nFact_2)): + return True + + return False + + +## nOrigInputNum = 5 +## print (IsBrillNum(nOrigInputNum)) + +nCount = 0 +nLoop = 4 + +while nCount < 20: + if IsBrillNum(nLoop): + print(nLoop) + nCount = nCount + 1 + + nLoop = nLoop + 1 -- cgit