GCD Function in Excel – Usage with Examples

GCD Function in Excel is used in calculations. It is an essential type of Mathematical Function in Excel. So let’s start learning the usage of the function.

When to use GCD Function in Excel?

GCD stands for Greatest Common Divisor. The GCD function in excel calculates the greatest common divisor of a set of numerical values. Greatest Common Divisor is a number that divides all the numbers in the set of values without leaving any remainder.

The function is helpful in many calculations where we need the greatest dividing value for the set of numbers.

Syntax and Arguments

=GCD(number1,[number2]……)

The following points will explain to you the required function arguments for the GCD Function in Excel.

  • number1 – This represents the first value of the set of numerical values. It can be a direct value, cell reference, a range of cells containing a set of numerical values, or a named range.
  • [number2] – This is an optional argument. It works the same as a number1.

There can be 255 such number arguments. Out of all these arguments, only the first argument number1 is mandatory to specify for normal function implementation.

Points to Remember about GCD Formula

Before we start working with GCD Function, the following points about the function must be known to you.

  • The GCD Function works only on integer type numerical values. If you supply the numbers with decimal place digits, then the digits after the decimal would be ignored. For instance, 4.234 would give results based on 4.
  • If you pass any negative value to the GCD formula, it would return a #NUM! error.
  • When any non-numerical value like a text string or a logical value ( like TRUE or FALSE ) is passed as the GCD Function argument, the function returns a #VALUE! error.
  • The function does not work for numbers greater than 2^53. Any number passed to function which is >=2^53 would give a #NUM! error.
  • GCD function considers blank cells as zero.
infographics GCD function in Excel

Examples to Implement the GCD Function in Excel

In this part of the blog, we would cover some of the practical experimentation with the GCD function formula in excel. So let’s do this.

Example 1 – Simplest Example for GCD formula

We would start by passing two numbers as the set of numerical values whose Greatest Common Divisor we want to find.

We are given the following values of number1 and number2 arguments.

gcd function in excel simple example raw data

Use the following GCD formula in cell C2.

=GCD(A2,B2)

We can also use the following formula in cell C2, it will return the same result.

=GCD(A2:B2)

Select the range C2:C8 and hit the ctrl D key to copy this formula for all the pairs of numbers.

gcd function in excel simple example result

As a result, the formula has returned the Greatest common divisor of 4 and 12 as 4.

Explanation – We have passed two numbers as the GCD function argument. The numbers are contained in cells A2 and B2. The function calculates the Greatest Common Divisor for the numbers and returns the corresponding results for all pairs of numbers.

Cell A5 contains the text string “Excel”. When we pass a text string as the GCD function argument, it returned a #VALUE! error in cell C5.

Cell A6 contains a negative value of -12. When we pass a negative value, the function returns a #NUM! error in cell C6.

Cell A8 contains a Logical TRUE due to which formula returned a #VALUE! error in cell C8.

Example 2 – Calculating GCD for more than Two Numbers

Let us suppose we have the set of numerical values containing three or four numbers as follows:-

gcd function in excel simple example raw data part 2

USe the following GCD formula to calculate the Greatest Common Divisor of the numbers in columns A, B, C, and D.

=GCD(A2:D2)

Copy this formula down the range E2:E4.

gcd function in excel simple example result part 2

As a result, the function returns the Greatest Common Divisor of the four numbers.

Explanation – We have passed the range A2:D2 as the number1 function argument. The function calculates the GCD. For the range A3:D3, the blank cell D3 did not affect the result. Also the value 12.23 in cell A4 in range A4:D4 was treated as 12 because the function works on integer part of the number.

This brings us to the end of blog.

Thank you for reading.

Leave a Comment