Code Below:
import java.util.*;
class smith
{
public static void main ()
{
Scanner s= new Scanner (System.in);
System.out.println("Enter a no.");
int n=s.nextInt();int d=n;
int a=0,b=0,c,i,j,x,su=0,sum=0,k,y,z;
for (i=1;i<=n;i++)
{
if (n%i==0)
a++;
}
if (a!=2)
{
for (j=2;j<=n;j++)
{
if (n%j==0)
{
y=j;
for (k=1;k<=j;k++)
{
if (j%k==0)
b++;
}
if (b==2)
{
z=j;
while (z>0)
{
c=z%10;
sum=sum+c;
z=z/10;
}
}
n=n/y;
j=1;
}
}
}
else
{
System.out.println ("no. is not composite");
}
while (d>0)
{
x=d%10;
su=su+x;
d=d/10;
}
if (su==sum)
System.out.println ("no. is smith no.");
else
System.out.println ("no. is not smith");
}
}