# Fascinating Number in Java3 min read

In this java program tutorial, we will learn about Fascinating Number and its implementation through Java. We will check whether the number Fascinating Number or not and also another program to find the find Fascinating Number within a given range in java.

## What is Fascinating Number?

A number is said to be a fascinating number if it is (having at least 3 digits) multiplied by 2 and 3, and then both these product’s results are concatenated with the original number, then the new number contains all the digits from 1 to 9 exactly once. There could be any number of zeros and are ignored.

Example:
Consider a Number = 192
Then multiply it by two and 3
192 × 2 = 384
192 × 3 = 576
Concatenating the above two numbers with the original number, we get:
`“192” + “384” + “576” = 192384576` = result.
Now the final result contains all the digits from 1 to 9. Hence it is a Fascinating Number.

## Procedure for Fascinating Number

1. First, check if the entered/given number has three digits or not. If not, print “cannot be a Fascinating Number”.
2. Else, Multiply the given number with 2 and 3.
3. Then convert the product result into a string and Concatenate those strings along with the original number.
4. Iterate the string that we get after concatenation and also keep the frequency count of the digits.
5. Print “Not a Fascinating Number” if any of the digits (1 to 9) is missing or repeated.
6. Else, print “It is a Fascinating Number”.

## Java Program for Fascinating Number

1. Write a Java program to check whether a number is fascinating or not.

Output:

`Enter 3 digit Number: 327 327 is a fascinating number. //Another Output Enter 3 digit Number: 145 145 is not a fascinating number.`

### 2. Java Program to find all the fascinating numbers between the given Range.

Output:

`Enter the Lower range: 1 Enter the Upper Range: 1000 The Fascinating number between 1 to 1000 are: 192 219 273 327 `

### Java Program to find the sum of the Largest Forward Diagonal

in this tutorial, we will write a java program to find the sum of the Largest Forward Diagonal in an Arraylist (matrix). Java Program to …

### C Program to search an element in an array using Pointers

A separate function( search_function()) will be created where the array pointer will be declared and the searched element along with the size of an array …

### C Program to find the sum of the digits of a number using recursion function

This C program calculates the sum of digits of a given number using recursion. Here’s a concise explanation: Function Definition: sumDigits(int n) This function calculates …

### C program to find factorial of a number using Ternary operator with Recursion

Recursion refers to the function calling itself directly or in a cycle. Before we begin, you should have the knowledge of following in C Programming: …

### C Program to Add Two Numbers Using Call by Reference

The program takes the two numbers from the user and passes the reference to the function where the sum is calculated. You may go through …

### Find the output ab, cd, ef, g for the input a,b,c,d,e,f,g in Javascript and Python

In this tutorial, we will write a program to find a pairs of elements from an array such that for the input [a,b,c,d,e,f,g] we will …