# Algorithm and Flowchart to check whether a Given Number is a Tech number or not

[3474 views]

### What are Tech numbers?

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 = 452 = 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.

### Algorithm to check whether a given number is Tech number or not:

Step 1: Start Step 2: Read the number from the user, say num Step 3: n = num Step 4: Initialize digit as 0 Step 5: WHILE n > 0, DO: 5.1: Increment digit by 1 5.2: n = n / 10 Step 6: End WHILE loop Step 7: IF digit % 2 = 0, THEN: 7.1: n = num 7.2: firsthalf = n % 10^digit/2 7.3: secondhalf = n / 10^digit/2 7.4: sum = (firsthalf+secondhalf) * (firsthalf+secondhalf) 7.5: IF sum = num, THEN: Display “Tech Number” 7.6: ELSE: Display “Not Tech Number” 7.7: End IF-ELSE Step 8: ELSE: 8.1: Display “Not Tech Number” Step 9: End IF-ELSE Step 10: Stop

### Explanation:

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.