forked from fenyx-it-academy/Class7-Python-Module-Week2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShatha_W2_Q4.py
More file actions
34 lines (26 loc) · 935 Bytes
/
Shatha_W2_Q4.py
File metadata and controls
34 lines (26 loc) · 935 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
#A palindromical prime number is a prime number that reads the same when reversed.
#Write a function which returns the nearest palindromical prime number less than the multiplication of all the arguments.
#Example
#Input1>>> some_function(2, 3, 4)
#Output1>>> the nearest palindromical prime number less than 24
#Input2>>> some_function(31, 77, 99)
#Output2>>> the nearest palindromical prime number less than 236,313
def plnd_prm (n1,n2,n3):
x=0
mult = n1*n2*n3
for i in range(mult,1,-1):
x=0
for j in range (i-1,1,-1):
if i%j == 0:
x= 1
break
if x == 0:
num_str = str(i)
new = num_str[::-1]
if num_str == new:
print(i)
break
num1 = int(input("Enter first number "))
num2 = int(input("Enter second number "))
num3 = int(input("Enter third number "))
plnd_prm(num1,num2,num3)