import java.io.*;
class FullPrime
{
public static void main(String args[])throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number: ");
int num = Integer.parseInt(br.readLine());
if(isPrime(num))
{
int n = num;
loop:
while(n != 0)
{
int d = n % 10;
switch(d)
{
case 2:
case 3:
case 5:
case 7:
n /= 10;
break;
default:
break loop;
}
}
if(n == 0)
System.out.println(num + " is full prime.");
else
System.out.println(num + " is not full prime.");
}
else
System.out.println(num + " is not full prime.");
}
public static boolean isPrime(int n)
{
int f = 0;
for(int i = 1; i <= n; i++)
{
if(n % i == 0)
f++;
}
return f == 2;
}
}
No comments:
Post a Comment
any problem in any program comment:-