wap to check the no. is twin prime or not . answer in short
Answers
Answered by
1
Answer:
Java?
import java.util.Scanner;
class TwinPrime {
public static void main(String[ ] args) {
System.out.println("Enter two numbers : ");
int a = new Scanner(System.in).nextInt();
int b = new Scanner(System.in).nextInt();
boolean prime = true;
for(int i = 2; i<=a/2; i++) {
if (a%i == 0)
prime = false;
}
for(int i = 2; i<=b/2; i++) {
if(b%i == 0)
prime = false;
}
if(prime)
System.out.println("Twin Prime");
else
System.out.println("not Twin Prime");
}
}
Similar questions