HCF/GCD of Two numbers Using Python

  Рет қаралды 77,249

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 230
@CodeWithHarry
@CodeWithHarry 4 жыл бұрын
Is playlist mei next video kya banau? Please suggest me some Python practice program topics? Python Practice Programs: kzbin.info/aero/PLu0W_9lII9agqZuv_XJen_BEHycIh-FmG C Practice Programs Playlist: kzbin.info/aero/PLu0W_9lII9ahSEQv6cHtu8JBXNgK2_QMX Instagram: instagram.com/codewithharry
@chamkaursingh7867
@chamkaursingh7867 4 жыл бұрын
Nice
@lakshyakumrawat
@lakshyakumrawat 4 жыл бұрын
Bhai pls cheat or hack any game using python
@AdarshSingh-cb5yf
@AdarshSingh-cb5yf 4 жыл бұрын
@@nakumgautam17 Ha bhai bahut jarurat hai mere ko bhi DS and Algo..... Lekin sir ne kai dino se vedio dala hi nhi 😕
@AdarshSingh-cb5yf
@AdarshSingh-cb5yf 4 жыл бұрын
Sir Ds and Algo please 😭😭😭😭... Bahut jarurat hai....
@shivankgarg1692
@shivankgarg1692 4 жыл бұрын
Bhai please DSA ki vdos upload krte raho
@hackerzone3292
@hackerzone3292 4 жыл бұрын
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...
@ankanderia4999
@ankanderia4999 3 жыл бұрын
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 ...!!
@anshumangupta6594
@anshumangupta6594 4 жыл бұрын
Harry sir : legend in the house of you tube
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
very true
@sarcarpit
@sarcarpit 4 жыл бұрын
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 !!
@IjazAhmad-wv9qx
@IjazAhmad-wv9qx 4 ай бұрын
this is more fast method then actual harry bha method. because there are chances for less comparison to hind HCF
@kacharumanke7090
@kacharumanke7090 4 жыл бұрын
Such a great teacher, who is still working on 2 years old project.
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
best teacher ever meet
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
@Prince Raj : )
@mohitgupta2699
@mohitgupta2699 4 жыл бұрын
@Prince Raj can you please explain your code
@mohitgupta2699
@mohitgupta2699 4 жыл бұрын
@Prince Raj you are my teacher , explain me
@MK-lu4pe
@MK-lu4pe 4 жыл бұрын
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-lu4pe
@MK-lu4pe 4 жыл бұрын
maine ye program pehle hi bana liya tha aapse hi Python sikh ke.
@MK-lu4pe
@MK-lu4pe 4 жыл бұрын
or maine Jarvis bhi banaya. jo meri konsi class kab suru hogi vo kehta hai and automatic browser open kar deta hai. itna hi nahi kab kya study karni hai or kab break lena hai vo sab time hote keh deta hai. me roj Jarvis update karta hu usme kuchh na kuchh new dalta rehta hu. dhire dhire real Jarvis ban raha hai. Thank you sir.
@atishayjain2205
@atishayjain2205 4 жыл бұрын
Bro when will you upload the next video for ds and algo playlist?
@mohitgupta2699
@mohitgupta2699 4 жыл бұрын
I already solve it on the day when you uploaded the lcm using python video By the way awesome video
@hackerzone3292
@hackerzone3292 4 жыл бұрын
Ekdam matlb no words to describe u harry bhai....wat a talent...really fan of u...
@dakshgarg775
@dakshgarg775 4 жыл бұрын
I am not first i am not last whenever i see your notification i click very fast
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
Nice one
@satyajitdas2780
@satyajitdas2780 4 жыл бұрын
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!
@radhapatel8536
@radhapatel8536 3 жыл бұрын
My program: a = int(input("Enter n: " )) l1 = [ ] for i in range(1,a+1): b = int(input("Enter the number: ")) l1.append(b) c = int(min(l1)) # HCF for i in range(1, c+1): for numbers in l1: if numbers%i == 0: HCF = i print("The HCF is " , HCF)
@uttkarsh7823
@uttkarsh7823 3 жыл бұрын
wrong code, let me correct your code and send you the correct one..
@radhapatel8536
@radhapatel8536 3 жыл бұрын
@@uttkarsh7823 print("Enter two numbers to calculate HCF ") a=int(input("Enter first number ")) b=int(input("Enter second number ")) while a%b !=0: rem=a%b a=b b=rem print("HCF is ", b)
@uttkarsh7823
@uttkarsh7823 3 жыл бұрын
@@radhapatel8536 yes, now correct, good
@codewithakshay7389
@codewithakshay7389 4 жыл бұрын
Sir lectures chal rahe hain college ke par yek like or view dene aaya hoon thanks Harry sir for wonderful videos of programming 😊😊💥💥💥💥
@abhiaryan07
@abhiaryan07 4 жыл бұрын
Bro please make a video on how to improve typing speed.... Your typing speed is awesome...
@vathsan3906
@vathsan3906 4 жыл бұрын
Practice
@prozeangamer4726
@prozeangamer4726 4 жыл бұрын
Herry bhai you are super 😎😎😎
@abhibiranje9517
@abhibiranje9517 3 жыл бұрын
Sir your method is good but I have better method with time complexity num1=int(input("Enter firat number ")) num2=int(input("Wnter second number ")) 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}")
@uttkarsh7823
@uttkarsh7823 3 жыл бұрын
method dusra nahi hai, bas mn/2 kiya hai, but still, good
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
Superb video sir
@omxky
@omxky Ай бұрын
This came in my school exams and no one turns out to be a batter teacher than you
@mayankjoshi8104
@mayankjoshi8104 4 жыл бұрын
harry bhai face detecton or face recognition in python banado please..
@jitendradashora8956
@jitendradashora8956 Жыл бұрын
def hcf(a, b): highest_common_factor = 1 for numbers in range(2, max(a, b)): if a % numbers == 0 and b % numbers == 0: highest_common_factor = numbers return highest_common_factor
@ashishkumarsharma2081
@ashishkumarsharma2081 Жыл бұрын
shouldn't u use min()?
@SnehaR380
@SnehaR380 Жыл бұрын
@@ashishkumarsharma2081 can u please help me out in my query I posted in comment section
@SnehaR380
@SnehaR380 Жыл бұрын
@@ashishkumarsharma2081 btw u sing really good man
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
you are awesome sir
@naturebgm-hz2zu
@naturebgm-hz2zu 10 ай бұрын
hcf undefined q show ho rha?
@ganeshmirisker4173
@ganeshmirisker4173 3 жыл бұрын
super explanation bro ,maza aagaya
@APStatus
@APStatus 3 жыл бұрын
# Find HCF Function def HCF(n1,n2): min = n1 while (True): if (n1 % min == 0 and n2 % min == 0): return min min -= 1 # Main function if __name__=="__main__": n1 = int(input("Enter The First Number : ")) n2 = int(input("Enter The Second Number : ")) n1, n2 = min(n1, n2), max(n1, n2) hcf = HCF(n1, n2) print(f"{n1} & {n2} HCF is {hcf}") # Abhishek Sharma
@mayanksandal
@mayanksandal 2 жыл бұрын
I have made my own code to find the HCF/GCD using sets in python.
@studies3943
@studies3943 2 жыл бұрын
# Here is a simpler way: a = int(input("Enter first:")) b = int(input("Enter second:")) while a % b != 0: remainder = a % b a = b b = remainder print("HCF is:", b)
@Mahnoor529
@Mahnoor529 Жыл бұрын
Can u explain this plaese
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
thank you so much sir
@PythonGuruji
@PythonGuruji 4 жыл бұрын
if you love harry bhai give like
@InvestWithAdarsh
@InvestWithAdarsh 4 жыл бұрын
True
@techmate8316
@techmate8316 3 жыл бұрын
Please also teach block based coding
@hackerzone3292
@hackerzone3292 4 жыл бұрын
Thnq sm harry bhai...😍♥♥♥
@RitikKumar-kd9up
@RitikKumar-kd9up 4 жыл бұрын
Thanks sir for clearing my concept for this question
@mohitgupta2699
@mohitgupta2699 4 жыл бұрын
@Prince Raj can you please explain your code
@saumyashrivastava7802
@saumyashrivastava7802 4 жыл бұрын
Bhaiya knsa laptop best hoga coding wgerh krne ke liye
@mdafroj8546
@mdafroj8546 2 жыл бұрын
Thank you sir 😎😍💝😍
@HARSHPIPAL
@HARSHPIPAL 4 жыл бұрын
Instead of updating the maximum value in for loop...we can simply run a loop in reverse direction from smaller number to 1.... correct?
@Pramod-wq7ef
@Pramod-wq7ef 3 жыл бұрын
I thought of the same approach bro...looping from the min no. till 1 and if there is any number divisible by both the given numbers, assign it as LCM and break the loop.
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
Nice video
@Pramod-wq7ef
@Pramod-wq7ef 3 жыл бұрын
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.
@uttkarsh7823
@uttkarsh7823 3 жыл бұрын
true
@rickk3300
@rickk3300 2 жыл бұрын
What if the numbers are 16 and 18? Then your approach will take more number of iterations. The point is it doesn't matter from which side you iterate....
@SnehaR380
@SnehaR380 Жыл бұрын
Yup that's what I was thinking def hcf(a, b): smaller = min(a, b) hcf = 1 for i in range(smaller,0,-1): if a%i == 0 and b%i == 0: hcf = i break return hcf a=int(input("1st no. ")) b=int(input("2nd no. ")) print(hcf(a,b))
@SnehaR380
@SnehaR380 Жыл бұрын
@@rickk3300 I am always getting 1 as answer on using sir's code because I think since i=1 satisfies it foremost it gives 1 as output whereas when I did by another approach i am.ways getting right hcf Why so?
@SnehaR380
@SnehaR380 Жыл бұрын
@@uttkarsh7823 I guess sir's approach is wrong
@SnehTalks
@SnehTalks 4 жыл бұрын
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
@__ayu
@__ayu 2 жыл бұрын
THANK YOU #CodeWithHarry
@29ibrahimsayed95
@29ibrahimsayed95 2 жыл бұрын
What a lovely explanation
@ritikjain6952
@ritikjain6952 4 жыл бұрын
Bhai plzzzzz Data structures and algorithms ki videos bhi upload kr do College teacher regularly takes class and he has completed 2 chapters (upto queue).....plzzzzzzzz
@niteshsharma595
@niteshsharma595 4 жыл бұрын
Make a motivational video.
@Boldunicorn
@Boldunicorn 4 жыл бұрын
Available with 3.9 and dict union ... beautiful feature, faster than previous
@creativeakshara8438
@creativeakshara8438 4 жыл бұрын
HARRY BHAI EK HEART DEDO I LOVE YOU BROTHER ♥️♥️
@faiyazahmad21
@faiyazahmad21 4 жыл бұрын
Thank you so much Harry bhai
@skepticaluniverse7632
@skepticaluniverse7632 4 жыл бұрын
you are great bro hats off to you effort
@chahatvamdev4088
@chahatvamdev4088 3 жыл бұрын
VERY INTERSTING SIR
@anshumanchoudhary2658
@anshumanchoudhary2658 2 жыл бұрын
import math math.gcd(40,12) output--4 this is right for gcd or not and why we are not using this , what is difference ?
@ashishkumarsharma2081
@ashishkumarsharma2081 Жыл бұрын
because the other program helps us understand the logic which this inbuilt function uses.
@Shivanilodhi31
@Shivanilodhi31 2 жыл бұрын
thank you very helpful
@thecoderguy2110
@thecoderguy2110 4 жыл бұрын
Amazing Playlist
@khadimhusen
@khadimhusen 4 жыл бұрын
Very good informative
@tanmaydaga4518
@tanmaydaga4518 4 жыл бұрын
When I learned python from ur playlist I also made this for my school purpose but my logic was way to long than ours.
@uttkarsh7823
@uttkarsh7823 3 жыл бұрын
My logic also very long
@DesiBozs007
@DesiBozs007 2 жыл бұрын
Thank you so much bhai
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
Get ready for 1M subscribers : )
@AKBMW-yh5ti
@AKBMW-yh5ti 3 жыл бұрын
Done
@devrajbhattacharya7912
@devrajbhattacharya7912 2 жыл бұрын
harry bhai thanku
@vardanbhaskar5222
@vardanbhaskar5222 4 жыл бұрын
Your videos are awesome bro:)
@omlanguagestudiogermanlang6260
@omlanguagestudiogermanlang6260 2 жыл бұрын
thanks
@ayushmanglamsingh4505
@ayushmanglamsingh4505 4 жыл бұрын
Nice Video 🔥🔥
@sonisinha8912
@sonisinha8912 4 жыл бұрын
Sir please make video series on unity game engine for game development and for game programming.....plz reply
@bakchodilive4020
@bakchodilive4020 4 жыл бұрын
Sir please make the video of pc building for programing language
@jagmohansaini6234
@jagmohansaini6234 3 жыл бұрын
Thanks sir
@rahulchaudhary5636
@rahulchaudhary5636 4 жыл бұрын
Bhai c practice video ni aayengi ab ?
@sudarshanmhaisdhune1039
@sudarshanmhaisdhune1039 3 жыл бұрын
Great one vro!=
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
kitni bar dill jetoge sir
@EzTechGyan
@EzTechGyan 4 жыл бұрын
Nice tutorial sir ❤️ Aap screen me konsa likhne ke liye kiska use krte ho???
@EzTechGyan
@EzTechGyan 4 жыл бұрын
Product Name bhi btaiye please 👍
@dhairyamehta8642
@dhairyamehta8642 4 жыл бұрын
5G se bhi fast video dalte ho sir
@creationduwal
@creationduwal 4 жыл бұрын
harry bhai math.gcd se bhi ho sakta hai na
@Bhanu4012
@Bhanu4012 4 жыл бұрын
Harry bhaiya op......
@RohanDasRD
@RohanDasRD 4 жыл бұрын
Great Video Brother
@nareshgoyal1994
@nareshgoyal1994 4 жыл бұрын
Harry bhai GCD ko Euclid division wale method se krke samjha do bhai.. Bahut problem aa rahi hai smjhne me
@SnehaR380
@SnehaR380 Жыл бұрын
Anyone please help me out I think that for loop must be run in reverse order in order to get highest value otherwise code would just return I=1 because ultimately that's the first value which satisfies if condition So I think code she be like this def hcf(a, b): smaller = min(a, b) hcf = 1 for i in range(smaller,0,-1): if a%i == 0 and b%i == 0: hcf = i break return hcf a=int(input("1st no. ")) b=int(input("2nd no. ")) print(hcf(a,b))
@SnehaR380
@SnehaR380 Жыл бұрын
I ran the above code and it worked
@SnehaR380
@SnehaR380 Жыл бұрын
On the other hand if I wrote for I in range (1,smaller+1) it was always giving 1 as answer
@faiyazahmad21
@faiyazahmad21 4 жыл бұрын
Harry bhai DBMS ka tutorial bna dijiye please
@pranjalkhatri5631
@pranjalkhatri5631 4 жыл бұрын
Tensorflow tutorial
@avibro7454
@avibro7454 4 жыл бұрын
Plz make a advance video for problem solving and making psudo code plzplzplzplzllz🙏🙏🙏🙏🙏
@pradeep_bhaiya2502
@pradeep_bhaiya2502 4 жыл бұрын
Cool harry bhai
@RohanSharma-tf3rw
@RohanSharma-tf3rw 4 жыл бұрын
Harry bhai laptop bataiye hp 15s du2067tu plz bataiye kaisa h student or coding ke liye
@nehamittal8310
@nehamittal8310 4 жыл бұрын
Please make tutorial series of kivy please reply
@acromatixgamer2291
@acromatixgamer2291 4 жыл бұрын
please teach us how to make a shooting game
@piyushbhardwaj9167
@piyushbhardwaj9167 4 жыл бұрын
Different types of patterns aur unki approach ko lekrr plzz plzz
@varshajawrani5153
@varshajawrani5153 4 жыл бұрын
Sir please continue java and data structure course playlist
@abheygupta2332
@abheygupta2332 4 жыл бұрын
Thanku sir
@shivanshutyagi83
@shivanshutyagi83 4 жыл бұрын
Harry bhai 👋👋
@prince6727
@prince6727 4 жыл бұрын
Sir Hardy Ramanujan number ke liye program banayi please
@JADE2238
@JADE2238 4 жыл бұрын
Harry Potter bhai 😂 make a tutorial on unreal engine 4
@someshsangwan5302
@someshsangwan5302 3 жыл бұрын
this code will shoe error if we takes input (0,b) here b is any number : def gcd(self, A, B): if A > B: smaller = B bigger=A else: smaller = A bigger=B if smaller==0: return bigger for i in range(1, smaller+1): if((A % i == 0) and (B % i == 0)): k=i return k
@ayushmourya812
@ayushmourya812 4 жыл бұрын
Harry bhai DS algo ki next video laaloooooooo.
@lakshyakumrawat
@lakshyakumrawat 4 жыл бұрын
Bhai pls cheat or hack any game using python
@shubhamteredesai
@shubhamteredesai 4 жыл бұрын
Harry bhai javascript mein phone keliye apps kaise banaye pl ek video banao
@mr.dominic9636
@mr.dominic9636 4 жыл бұрын
React Js plzzzzz
@aditgaur1585
@aditgaur1585 4 жыл бұрын
11:26 Code With Eminem 😂
@devashishprajapati9860
@devashishprajapati9860 4 жыл бұрын
Sir ji e commerces website per series banao
@priyadubey9643
@priyadubey9643 Жыл бұрын
Sir last print ki bad ( ) me f ka ya Matlab hai
@abhishekthakur01608
@abhishekthakur01608 Жыл бұрын
formating string
@volcenoXpo2003
@volcenoXpo2003 Жыл бұрын
Last line print(f"The gcd of these two number is {hcf}") Why do u use' f ' key
@naturebgm-hz2zu
@naturebgm-hz2zu 10 ай бұрын
hcf undefined q show ho rha?
@Lila12386
@Lila12386 4 жыл бұрын
Python guru
@lakshyakumrawat
@lakshyakumrawat 4 жыл бұрын
Bhai pls cheat or hack any game usinh python
@sannidhyakushwaha2561
@sannidhyakushwaha2561 4 жыл бұрын
Bro make playlist on Flutter app development.
@omkarsingh3702
@omkarsingh3702 4 жыл бұрын
Harry if we are in 9th class can we learn artificial intelligence or machine learning please tell me
@Pramod-wq7ef
@Pramod-wq7ef 3 жыл бұрын
it depends on what you want to acheive after learning bro
@mdfarman9786
@mdfarman9786 2 жыл бұрын
I can get LCM numbers from input using python
@_ARIC_KAJI
@_ARIC_KAJI 4 жыл бұрын
sir ji how to make a gui program that you enter the data in entry box and you click the button print your data is print in the hard copy . like this Name : harry bhai sir ji please reply
@suneelpandita8632
@suneelpandita8632 4 жыл бұрын
Day 4 of commenting:Make PyQt5 tutorial Bhai
Python Program to Check Armstrong Number
18:08
CodeWithHarry
Рет қаралды 102 М.
Program to calculate HCF of two numbers in C language
14:39
MySirG.com
Рет қаралды 184 М.
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 69 МЛН
It works #beatbox #tiktok
00:34
BeatboxJCOP
Рет қаралды 13 МЛН
How many people are in the changing room? #devil #lilith #funny #shorts
00:39
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,5 МЛН
What Do Software Engineers Actually Do? (It’s Not What You Think)
13:07
5 Mistakes Beginner Web Developers Make (Avoid These)
12:09
CodeWithHarry
Рет қаралды 99 М.
GCD - Euclidean Algorithm (Method 1)
14:38
Neso Academy
Рет қаралды 615 М.
Top Skills to Learn in 2025
9:31
CodeWithHarry
Рет қаралды 83 М.
Python Program to Multiply Two Matrices
18:13
CodeWithHarry
Рет қаралды 63 М.
Lamborghini vs Smoke 😱
00:38
Topper Guild
Рет қаралды 69 МЛН