[5478 views]

A number is said to be a Tech number when it has even number of digits and the number can be split into two parts, where the square of the sum of the two halves is equal to the original number. For example: 2025, 3035, etc.

Let us consider the number 2025:

Number of digits: 4

2025 can be split into: ‘20’ and ‘25’

Square of sum of the numbers: (20+25)^{2} = 45^{2} = 2025

Therefore, 2025 is a Tech number.

In this article, we will learn about the algorithm and flowchart to check whether a given number is Tech number or not, followed by a brief explanation of the algorithm for better understanding.

In this problem, we need to check whether a given number is a Tech number or not. To check this, we need to find out the number of digits of the number first. If the number of digits is even, we have to divide the number into two equal halves. If the square of the sum of these halves is equal to the original number, then the given number is a tech number.

The algorithm starts off by taking the number to be checked as user input. The value is then stored in a variable, say ‘n’. We keep a copy of this number in a variable ‘num’. We now initialize number of digits in the number as zero. To count the number of digits, we start a loop that runs until the number is greater than zero. In each iteration, we increment the digit and remove the last digit of the number. Once we get the total digits, we check whether digit is even or odd. If digit is even, we divide the number into two parts. The first part is equal to the first digit/2 digits of the number and the second part contains the last digit/2 digits.

Once we get these numbers, we find out the square of the sum of these numbers. If the sum is equal to the original number ‘n’, then we display “Tech Number”, else we display “Not Tech Number”. If the number of digits is odd, we display “Tech Number”, else we display “Not Tech Number”.

Note: Here ‘%’ is the modulus operator which returns the remainder value after division.

Let us consider an example:

Let num = 3035

digit = 4

firsthalf = 30

secondhalf = 35

sum = (30+35)^{2}

= 652

=3035

Therefore, sum = num = 3035.

Hence, 3035 is a tech number.

- Algorithm and Flowchart to check whether a number is a spy number or not
- Algorithm and Flowchart for N Queen Problem with Simple Explanation
- Algorithm and Flowchart to display Floyd’s Triangle
- Flowchart and Algorithm for calculating X to the Power of Y i.e X
^{Y} - Algorithm and flowchart to perform binary to octal conversion