0
import java.io.*;
class Smith
{
public static void main(String[]args)throws IOException
{
BufferedReader k=new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter a Number");
int n=Integer.parseInt(k.readLine());
int i,p=n,c,j,a,r,s=0,s1=0;
// SUM OF DIGITS...
while(p>0)
{
s1+=p%10;
p/=10;
}
System.out.println("SUM OF NOS:"+s1);
// SUM OF PRIME FACTORS...
p=n;
for(i=1;i<=n;++i)
{
c=0;
for(j=1;j<=i;++j)
if(i%j==0)
c++;
if(c==2)
{
while(p%i==0)
{
a=i;
r=0;
while(a>0)
{
r+=a%10;
a/=10;
}
s+=r;
p/=i;
}// end of outer while-loop
}// end of if block.
}// end of for loop.
System.out.println("SUM OF PRIME FACTORS: "+s);
if(s==s1)
System.out.println("IT IS A SMITH NO.");
else
System.out.println("NOT A SMITH NO.");
}
}
/*
OUTPUT:
Enter a Number
666
SUM OF NOS:18
SUM OF PRIME FACTORS: 18
IT IS A SMITH NO.
*/
class Smith
{
public static void main(String[]args)throws IOException
{
BufferedReader k=new BufferedReader (new InputStreamReader(System.in));
System.out.println("Enter a Number");
int n=Integer.parseInt(k.readLine());
int i,p=n,c,j,a,r,s=0,s1=0;
// SUM OF DIGITS...
while(p>0)
{
s1+=p%10;
p/=10;
}
System.out.println("SUM OF NOS:"+s1);
// SUM OF PRIME FACTORS...
p=n;
for(i=1;i<=n;++i)
{
c=0;
for(j=1;j<=i;++j)
if(i%j==0)
c++;
if(c==2)
{
while(p%i==0)
{
a=i;
r=0;
while(a>0)
{
r+=a%10;
a/=10;
}
s+=r;
p/=i;
}// end of outer while-loop
}// end of if block.
}// end of for loop.
System.out.println("SUM OF PRIME FACTORS: "+s);
if(s==s1)
System.out.println("IT IS A SMITH NO.");
else
System.out.println("NOT A SMITH NO.");
}
}
/*
OUTPUT:
Enter a Number
666
SUM OF NOS:18
SUM OF PRIME FACTORS: 18
IT IS A SMITH NO.
*/
jalaj
Dec 03, '13
2 answers
0
0
import java.util.*;
class smith
{
public static void main(String[]args)throws Exception
{
int i,m,p=1,s=0;
Scanner d =new Scanner(System.in);
System.out.println("enter");
int n=d.nextInt();
m=n;
for(i=1;i<n;i++)
{
if(m%i==0&&p<n&&(prime(i)==1))
{
s+=sum(i);
m=m/i;
i--;
p=p*i;
}
}
if(s==sum(n))
System.out.println("Yes");
else
System.out.println("no");
}
public static int prime(int n)
{
int i,s=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
s++;
}
return(s-1);
}
public static int sum(int n)
{
int i,x=0;
for(i=n;i>0;i=i/10)
{
x=x+(i%10);
}
return(x);
}
}
itsmeharsh
Feb 16, '14
Log in to your account to answer this questions.