c
  1. c-program-to-find-gcd-using-recursion

Program to Find G.C.D Using Recursion - (C Programs)

Heading

Given two numbers, find their G.C.D (Greatest Common Divisor) using recursion in the C programming language.

Example

Let's take two numbers 48 and 60. We will find their G.C.D using recursion.

Input

int num1 = 48, num2 = 60;

Output

G.C.D of 48 and 60 is: 12

Explanation

The G.C.D of two numbers is the largest positive integer that divides each of the numbers without a remainder.

The following steps can be used to find the G.C.D of two numbers using recursion:

  1. If the second number is 0, then the G.C.D is the first number.
  2. Otherwise, recursively call the function with the second number as the first parameter and the remainder of the division of the first and second numbers as the second parameter.

Use

This program can be used to find the G.C.D of two numbers. It can be used in various mathematical problems where finding the G.C.D is necessary.

Summary

In this program, we have seen how to find the G.C.D of two numbers using recursion in the C programming language. Recursion is a powerful technique that can be used to solve complex problems in a simple and elegant manner.

Published on: