Javatpoint Logo
Javatpoint Logo

Tech Number in Java

In this section, we will learn what is tech number and how can we find tech numbers through a Java program.

Tech Number

A number is called a tech number if the given number has an even number of digits and the number can be divided exactly into two parts from the middle. After equally dividing the number, sum up the numbers and find the square of the sum. If we get the number itself as square, the given number is a tech number, else, not a tech number. For example, 3025 is a tech number.

Tech Number Example

Let's take an example and check 2025 and 1312 are tech numbers or not.

Tech Number in Java

Steps to Find Tech number

The base condition to check the tech number is that the number must contain an even number of digits. If so, we will move to the next step, else will not execute the code further. Let's see the steps.

  • Read or initialize a number (num).
  • Find the number of digits of the given number (num).
  • If the number of digits is not even, the number (num) is not even.
  • Else, split the given number into two parts (num1 and num2), equally. Note that each part must contain an equal number of digits.
  • Sum up the numbers (num1+num2) and store the result in a variable
  • Find the square of the variable sum and store it in a variable square.
  • Compare the num with the square of the sum if they are equal print Tech Number, else print Not a Tech Number.

Tech Number Java Program

Let's create a Java program and check whether the number is tech or not.

TechNumberExample1.java

Output 1:

Enter a number to check: 2025
2025 is a tech Number.

Output 2:

Enter a number to check: 9181
9181 is not a tech number.

Let's find all the tech numbers between a specified range.

TechNumberExample2.java

Output:

Tech numbers between 1 to 1000000 are: 
1
2025
3025
9801
10000

Let's see another logic for the same.

TechNumberExample3.java

Output:

Enter the number to check: 3025
The given number is a tech number.






Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA