-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdigitPrimes.py
More file actions
42 lines (39 loc) · 743 Bytes
/
digitPrimes.py
File metadata and controls
42 lines (39 loc) · 743 Bytes
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
33
34
35
36
37
38
39
40
41
def checkPrime(n):
for x in range(2,int(n**0.5)+1):
if not n%x:
return False
return True
def generatePrimes(up,low):
plist=[]
for x in range(up,low+1):
if checkPrime(x):
plist.append(x)
return plist
def digitSum(n):
sum=0
while n:
sum+=n%10
n//=10
return sum
def generatedigitPrimes(up,low):
dplist=[]
primeslist=generatePrimes(up,low)
for x in primeslist:
if checkPrime(digitSum(x)):
dplist.append(x)
return dplist
def main():
s=input().split(" ")
uplim=int(s[0])
lowlim=int(s[1])
index=int(s[2])
dprimes=generatedigitPrimes(uplim,lowlim)
print(dprimes)
if index<len(dprimes):
print(dprimes[index])
else:
print("No number at this index")
main()
def arug():
print(s) for s in range(1,10)
arug()