HCF/GCD of Two numbers Using Python

preview_player
Показать описание
Get this course at 90% Discount if you use this link

Calculation of HCF Using Python: In this video, we will learn to find the GCD of two numbers using Python. Python Program to Find HCF or GCD is asked very often in the exams and we will take this up in todays video!
Highest Common Factor or Greatest Common Divisor of two or more integers when at least one of them is not zero is the largest positive integer that evenly divides the numbers without a remainder. For example, the GCD of 8 and 12 is 4

Best Hindi Videos For Learning Programming:

►C Language Complete Course In Hindi -

►JavaScript Complete Course In Hindi -

►Django Complete Course In Hindi -

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

Is playlist mei next video kya banau? Please suggest me some Python practice program topics?
Instagram: instagram.com/codewithharry

CodeWithHarry
Автор

Yaar harry bhai...aapko ek salute bhai...hats off..
Mera aaj Data structure xam tha aaj...kuch bhi nai ata tha..
Sirf apki videos dek ke xam ko gaya hu bhai...aur 60-70mrks takk likh ke aya hu..sab aapke waja se bhai....dil se thanq soo much bhai...

hackerzone
Автор

def GCD(a, b):
minNum = min(a, b)
maxNum = max(a, b)
rem = 1
while True:
rem = maxNum % minNum
if(rem == 0):
break
maxNum = minNum
minNum = rem

return minNum


a = int(input("Enter first number : "))
b = int(input("Enter second number : "))

result = GCD(a, b)
print(result)



# we can do like that ...!!

ankanderia
Автор

Such a great teacher, who is still working on 2 years old project.

kacharumanke
Автор

Bro when will you upload the next video for ds and algo playlist?

atishayjain
Автор

sir i tried it myself and i came up with a different logic . Please check if I m correct?
a = int(input("Enter the first number : "))
b = int(input("Enter the second number : "))
hcf=1
i=min(a, b)
while i>1:
if a%i==0 and b%i ==0:
hcf=i
break
i=i-1

print(f"The HCF of {a} & {b} is : {hcf} ")
I have learnt Python from your channel only!!
you're the BEST !!

sarcarpit
Автор

Harry sir : legend in the house of you tube

anshumangupta
Автор

Harry Praji! bahut sahi concepts with code hai? aise hi concepts wale videos banayiye jo interview mwi puchte ho, wo substring, subsequence, anagrams, catalon numbers, bhai how to identify recursion and solving by recursion! Bhai apse badiya koi nahi samjata hoin. Thank you Praji!

satyajitdas
Автор

Harry sir I am current in 10th. class 10th me maths ke 1st ch me HCF and LCM find karne ke bahut sare question he. isliye maine kam aasan karne ke liye HCF and LCM find karne ka Python program banaya tha. maine aapse hi python sikhi hai. Thank you so much Harry sir.

MK-lupe
Автор

I already solve it on the day when you uploaded the lcm using python video

By the way awesome video

mohitgupta
Автор

Ekdam matlb no words to describe u harry bhai....wat a talent...really fan of u...

hackerzone
Автор

I am not first
i am not last
whenever i see your notification
i click very fast

dakshgarg
Автор

Sir lectures chal rahe hain college ke par yek like or view dene aaya hoon thanks Harry sir for wonderful videos of programming 😊😊💥💥💥💥

codewithakshay
Автор

This came in my school exams and no one turns out to be a batter teacher than you

omxky
Автор

harry bhai face detecton or face recognition in python banado please..

mayankjoshi
Автор

Bro please make a video on how to improve typing speed.... Your typing speed is awesome...

abhiaryan
Автор

Harrybhai mera ek question hai..
Apne jarvis vali video me bataya tha ki 'hum additional voices bhi run kara sakte hai ..' .. bt mene google pe bahot dhunda prr iska genuine solution muje nahi nhi mil rha...

Kya aap please iss topic pe video baanyenge ki kese hum vo dono voices(david and zera) ke alawa additional voices kese aur kaha se use kara sakte hai ????... Plzz bhaiya kuch batana

SnehTalks
Автор

Sir your method is good but I have better method with time complexity
num1=int(input("Enter firat number\n"))
num2=int(input("Wnter second number\n"))

if num1>num2:
mn=num2

else:
mn=num1

for i in range(1, int((mn/2)+1)):
if num1%i==0 and num2%i==0:
hcf=i

if num2%num1==0:
hcf=num1

print(f"Your HCF is {hcf}")

abhibiranje
Автор

Bro I have another approach, instead of looping from 1 till min number and updating hcf every time, we can loop from the min of two numbers till 1 and if we find a factor for both, we assign it as hcf and break the loop. I guess this approach might reduce the num of iterations.

Pramod-wqef
Автор

Bhai Data structures and algorithms ki videos bhi upload kr do
College teacher regularly takes class and he has completed 2 chapters (upto

ritikjain
welcome to shbcf.ru