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

Logic Gates for ISC Class 11: Truth Tables, Universal Gates, Half and Full Adder
ISC Class 11 Computer Science notes on logic gates: AND, OR, NOT, NAND, NOR, XOR and XNOR with truth tables, why NAND and NOR are universal gates, and half adder and full adder circuits with their Boolean expressions.
Decimal to Binary Conversion in Java: 3 Programs with Examples
How to convert a decimal number to binary on paper and in Java: three programs (String, place value and Integer.toBinaryString), binary to decimal, a dry run and common mistakes.

ISC Class 11 Computer Science Sample Paper 2026-27 with Solutions
A full 70-mark ISC Class 11 Computer Science sample paper for the 2026-27 annual exam: MCQs, number systems, propositional logic, logic gates, Java classes, arrays, strings, searching and sorting, and computing ethics, with complete worked solutions.