0

Wap to input a number and check whether it is twin prime or not

7th May 2020, 9:29 AM
Aksha Shahnwaz
Aksha Shahnwaz - avatar
7 odpowiedzi
+ 2
def prime(n) : c=0 for i in range (2,n): if (n%i==0): c+=1 break return (c) n1=int(input ("Enter a number")) n2=int(input ("Enter a number")) X=prime(n1) Y=prime (n2) if (x==0) and (y==0) and (n1-n2 ==2) and (n2-n1 ==2) : print ("Twin prime number") else : print ("Not a twin prime")
7th May 2020, 9:35 AM
Aksha Shahnwaz
Aksha Shahnwaz - avatar
+ 2
We should not present codes here, if someone is asking for it. We should request for a code or attempt that the akser has done (posted and linked in sololearn). On a short term it may be helpful for the asker to get something ready to use, but on a long term this is not the case. Lets give people hints or a sequence of pseudo code, or some other helpful things. Thanks!
7th May 2020, 10:54 AM
Lothar
Lothar - avatar
+ 1
Thnxx Kiibo for the correction 😄
8th May 2020, 6:06 PM
Aksha Shahnwaz
Aksha Shahnwaz - avatar
0
Plzzz check if the program is correct
7th May 2020, 9:35 AM
Aksha Shahnwaz
Aksha Shahnwaz - avatar