This program takes two positive integers and calculates GCD using recursion. Visit this page to learn how you can calculate the GCD using loops. Example: GCD of Two Numbers using Recursion fun main(args: Array<String>) { val n1 = 366 val n2 = 60 val hcf = hcf(n1, n2) println("G....
n2 : -n2; while(n1!=n2) { if(n1 > n2) n1 -= n2; else n2 -= n1; } printf("GCD = %d",n1); return 0; } Output Enter two integers: 81 -153 GCD = 9 You can also use recursion to find the GCD.Share on: Did you find this article helpful?
Power using Recursion in C C Program to Calculate the Power using Recursion Product of two Numbers using Recursion in C C Program to Find Product of Two Numbers using Recursion Product of two Numbers without Recursion in C C Program to Find Product of Two Numbers without Recursion Nth Fibonacci...
Write a C program to calculate the sum of the squares of the digits of a number using recursion. Write a C program to recursively compute both the sum and product of the digits of a number.C Programming Code Editor:Click to Open Editor Previous...
C Program to Find GCD of two Numbers C Program to Find LCM of two Numbers C Program to Display Characters from A to Z Using Loop C Program to Count Number of Digits in an Integer C Program to Reverse a Number C Program to Calculate the Power of a Number C Program to Check...
C Program Write a Program to Find the Greatest Between 3 Number Write A C++ Program To Find Greatest Number Among Three Integer Numbers. Greatest Common Divisor Using Recursion Java Example How to calculate the GCD (Greatest Common Divisor) in Java C Program Write a Program to Enter Char...
C Program to find GCD of two numbers C Program to find LCM of two numbers C Program to check whether number is prime or not C Program to count number of digits in an integer C Program to calculate the power of a number C Program to print prime numbers from 1 to 100 (1 to N) ...
Calculate nCr Using Function Check If A Array Is Sorted Or Not Using Recursion Check A String Is Palindrome Or Not Using Recursion Check Pythagorean Triplets Count Zeros In A Number Print Fibonacci Sequences Using Function Find First And Last Occurrence Of Element In An Array Using Recursion Frien...
Added Program to calculate Modular Exponents Quickly finding the first missing natural number Finding the first missing natural number gcd.c updated gcd.c file with better functionality getPIDs.c added a program to get all PIDs that is used by parent and child in a… heap sort.c fixed the...
118. Print Pattern Using C 08:38 119. C Program to Print Pyramid Pattern Using _ 10:32 120. Learn to make Program to Calculate 100 Factorial (0 to 100) in C 12:56 121. How to program pyramids using loops - 5 19:59 122. C Tutorial 29 - Reading and Writing to Files - fs...