Fascinating Number program Solved ISC practical 2021 Question 1
Fascinating Number program Solved ISC…: solved Java program for ISC Class 12 Computer Science with complete BlueJ code, explanation and sample output.
Fascinating Number program
Frequency of letters
import java.util.*;
class Fascinating
{
/* joins n, 2n and 3n: for 192 it returns "192384576" */
String mergeNum(int n)
{
return Integer.toString(n) + Integer.toString(n * 2) + Integer.toString(n * 3);
}
/* a fascinating number's merged form contains every digit 1 to 9 exactly once (and no 0) */
boolean isFascinating(int n)
{
String m = mergeNum(n);
if (m.length() != 9)
return false;
for (char d = '1'; d <= '9'; d++)
{
if (m.indexOf(d) == -1)
return false;
}
return true;
}
public static void main()
{
Fascinating obj = new Fascinating();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the lower limit greater than 99");
int lo = sc.nextInt();
System.out.println("Enter the upper limit less than 10000");
int ul = sc.nextInt();
if (ul < lo || ul >= 10000 || lo <= 99)
{
System.out.println("INVALID INPUT");
return;
}
int count = 0;
System.out.println("THE FASCINATING NUMBERS ARE:");
for (int j = lo; j <= ul; j++)
{
if (obj.isFascinating(j))
{
System.out.print(j + " ");
count++;
}
}
if (count == 0)
System.out.print("NIL");
System.out.println();
System.out.println("FREQUENCY OF FASCINATING NUMBERS IS: " + count);
}
}
http://www.youtube.com/trushnatej
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.