Computer Science, asked by harsha116, 10 months ago

write a program in Java to accept a no. N check if it is a twisted prime no. Or not

Answers

Answered by SnehaG
4
\color{blue}\huge\bold\star\underline\mathfrak{Bonjour\:Mate}\star

\color{violet}\huge\bold\star\underline\mathcal{Here\:Is\:Ur\:AnSweR}\star

\color{red}\huge\bold\star\underline\mathfrak{ComPuteR\:ScienCe\:MiStresS}\star

Here we go,

import java.io.
*;public class twistedprime{ public static void main(String args[])
throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int n, r, m, i, j, g, s=0, k=0, c=0; System.out.println("Input a number"); n=Integer.parseInt(br.readLine());
m=n; int p=m;
while(m!=0) { r=m%10; s=(s*10)+r; m=m/10; } for(i=1;i<=n;i++)
{ if(n%i==0) { k++; } } for(j=1;j<=s;j++) { if(s%j==0) { c++; } } if(k==2&c==2) {  System.out.println(p+" is twisted prime"); } else { System.out.println(p+" is not twisted prime"); } }}

\color{brown}\huge\bold\star\underline\mathfrak{thanks}\star
Similar questions