Computer Science, asked by samantakoushik07, 9 months ago

Write a method to display twin prime numbers that lie between a given range by the user.​

Answers

Answered by Kaushikkalesh
0

x, y = input().split()

a = int(x)

b = int(y)

arr = [ ]

for i in range(a, b):

for j in range(2,b):

if i%j == 0:

arr.append(i)

sol_arr = [ ]

for i in range(0,b):

if arr[i+1] - arr[i] == 2:

sol_arr.append((arr[i], arr[i+1]))

print("The Twin Primes between ", str(a), " and ", str(b), " are ")

for i in sol_arr:

print(i, sep=', ')

Note - The Code is in Python

Please Thank Me

And Mark this as Brainliest

Similar questions