Skip to main content

Posts

Showing posts from April, 2022

Euclid's Division Lemma - Program

Hello Everyone, how y'all are fine. In this blog, we are gonna try to build program for Euclid's Division Lemma. It just a mathematical theorem that states that "Given positive integers a and b, there exist unique integers q and r such that a = bq +r, 0 <  r < b". Here basically 'a' is dividend, 'b' is divisor, 'q' is quotient and 'r' is remainder. This is user to find the HCF(Highest Common Factor) of two numbers. We are going to build program to do exactly that. I am using C programming language, however this can be done using any programming language. So I created a new C program file using vim and I used the below code.    ======= Code ======= #include <stdio.h> void main(){         int num1,num2,a,b,q,r;         printf("Enter a number: ");         scanf("%d",&num1);         printf("Enter another number: ");         scanf("%d",&num2);     ...