I have a program which I've written in Python. It is a program that determines whether a given input integer is a twin prime or not. This is the Python program I've written below:
from math import*
def is_prime(x):
check1 = 0
for i in range(2,x):
if i != x:
check = x%i
if check == 0:
check1 = 1
break
if check1==1:
return False
else:
return True
def is_twin_prime(x):
if is_prime(x)==True:
n = x + 2
n1 = x-2
if is_prime(n)==True or is_prime(n1)==True:
return True
else:
return False
else:
return False
numbers = []
N = int(input())
for i in range(N):
p = int(input())
numbers.append(p)
for j in numbers:
if is_twin_prime(j)==True:
print("true")
else:
print("false")
May someone please guide me on how to convert this entire program to C++?
Thank you.
Aucun commentaire:
Enregistrer un commentaire