aboutsummaryrefslogtreecommitdiff
path: root/challenge-164/eric-cheung/python/ch-1.py
blob: 92040209e1d135ca0acb1631a2a99229fe2c892b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
arrPrime = []
arrIsPalindromePrime = []

def IsPrime(nInput):
    for primeLoop in arrPrime:
        ## print (primeLoop)
        if nInput % primeLoop == 0:
            return False

    return True

def IsPalindrome(strInput):
    if strInput == strInput[::-1]:
        return True

    return False

arrPrime.append(2)
arrPrime.append(3)

arrIsPalindromePrime.append(2)
arrIsPalindromePrime.append(3)

for nLoop in range(5, 1000):
    if IsPrime(nLoop):
        arrPrime.append(nLoop)
        if IsPalindrome(str(nLoop)):
            arrIsPalindromePrime.append(nLoop)

## print (arrPrime)
print (arrIsPalindromePrime)