Program to check Fascinating Number in Java

In this tutorial you will learn about the Program to check Fascinating Number in Java and its application with practical example.

In this tutorial, we will learn to create a Java Program to check Fascinating Numbers in Java using Java programming.

Table Of Contents

Prerequisites

Before starting with this tutorial we assume that you are best aware of the following Java programming topics:

  • Java Operators.
  • Basic Input and Output function in Java.
  • Class and Object in Java.
  • Basic Java programming.
  • If-else statements in Java.
  • For loop in Java.

What is Fascinating Number?

In Mathematics, any 3-digit number is said to be a fascinating when the base number is multiplied by 2 and 3 respectively and the outcome of the 2 multiplication are concatenated with base number and there is no repeated number in the concatenated number, i.e. from 1 to 9 all are occurred once in the number here. 0 are ignored in the final outcome number. If any number from 1 to 9 is repeated then that number is not a fascinating number

 

Java Program to check the number is fascinating number

In this program we would find the given number is fascinating number first will take the input from the user and check whether it is a3-digit number or not. If it’s not a 3-digit number then the program will be terminated. Then if the number is a 3-digit number then the program will continue and check the number. The fascinating number is a commonly asked question in coding tests of java.

For example, 192 to be checked

Then

192

192*2=384

192*3=576

“192” + “384” + “576” = 192384576

Here the above number doesn’t repeat any number hence it is a fascinating number.

Output

 

In this tutorial we have learn about the Program to check Fascinating Number in Java and its application with practical example. I hope you will like this tutorial.