Smith Number: simple & Easy
Smith Number: solved Java program for ISC Class 11 Computer Science with complete BlueJ code, explanation and sample output.

Smith Number the sum of digits is equal to the sum of the digits of all its prime factors.
One example of it is 666.
As 666= 2 * 3 * 3 * 37
Since 6+6+6(sum of digits)=2 + 3 + 3 + (3+7)(sum of factors digits) = 18
Watch java videos
import java.io.*;
class SmithNumber
{
static int s=0;
public static int sumdig(int n)
{
if(n==0)
{
return 0;
}
else
{
int d=n%10;
return(d+sumdig(n/10));
}
}
static int sum=0;
public static int prime_sum(int n,int i)
{
if(n>1)
{
if(n%i==0)
{
sum=sum+sumdig(i);
return(prime_sum(n/i,i));
}
else
{
return(prime_sum(n,i+1));
}
}
else
{
return sum;
}
}
public static void main()throws IOException
{
System.out.println("Enter the number");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
int num=Integer.parseInt(br.readLine()); int res1=sumdig(num);
int res2=prime_sum(num,2);
if(res1==res2)
{
System.out.println("This number is smith");
}
else
{
System.out.println("NOT SMITH NUMBER");
}
}
}Output:
Enter the number
666
This number is smith
Download free Sample papers
Related Posts
Continue learning with these related articles

ISC Practical 2027: Image Editor – Brighten an Image and Find Bright Spots (2-D Array) – Java Program
Fully solved ISC Computer Science Practical 2027 2-D array question: brighten a grayscale image (capping values at 255) and find the bright spots, pixels larger than all four neighbours. Includes a missing bright spot in CISCE’s sample output.

ISC Practical 2027: College Enrolment Code Validator and Stream Report – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 question: validate college enrolment codes made of a stream, year and serial number, give the exact reason for each rejection, auto-correct lowercase streams and prepare a stream-wise report.

ISC Practical 2027: Digital Lock Security Code Analyzer – Algorithm and Java Program
Fully solved ISC Computer Science Practical 2027 number-logic question: for a 5 to 10 digit security code, find the first and last digits, odd and even position sums, product of non-zero digits, digit frequency and classify the code as STRONG, MODERATE or WEAK.