Python Tutorials - Program To Find out the GCD of Two Positive Numbers

  Рет қаралды 124,847

Amulya's Academy

Amulya's Academy

6 жыл бұрын

In this Python Pattern Programming video tutorial you will learn to find out the gcd of two positive numbers with example.
GCD stands for Greatest Common Divisor it is also called as HCF (Highest Common Factor)
GCD of two positive number is nothing but it is the greatest number which will divide both the number completely.
We can use gcd() or Euclid's algorithm to find out the gcd of two numbers.
For more free tutorials on computer programming
/ amulsacademy
/ amulsacademy

Пікірлер: 219
@infinitygaming7192
@infinitygaming7192 2 жыл бұрын
Easy method Def(num1,num2) Lis = [] For i in range (0,num1): If num1 % i ==0 and num2 % i ==0: Lis.append(i) Return lis[-1]
@kellymirandalobo9353
@kellymirandalobo9353 2 жыл бұрын
i really like the way you explain coding!! so clear and to the point! really thanks for the vid!
@smestartup8561
@smestartup8561 4 жыл бұрын
Thanks you for your clear step-by-step explanation on Euclidean algorithm using small case, 64 & 48. I could understand "why 'a' should be returned " clearly and the recursive function a little bit more. I have subscribed!! I hope you and your beloved ones staying healthy and happy.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you so much :) Stay happy Stay Healthy :)
@tlbb1216
@tlbb1216 5 жыл бұрын
Your channel is fantastic! There's no word to describe my gratitude to you
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you :)
@NeerajSingh-hu9ut
@NeerajSingh-hu9ut 2 жыл бұрын
Thanks for the simple and pre-concept explanation. Thanks again !
@kwekoweprince5077
@kwekoweprince5077 5 жыл бұрын
You are AMAZING!!! You explained it perfectly!!!!! I subscribed
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Thank you :)
@mamagrace6208
@mamagrace6208 3 жыл бұрын
subscribed as well.
@debojitmandal8670
@debojitmandal8670 3 жыл бұрын
@@AmulsAcademy mam I don't understand the explanation bcs when you used return why only a is getting printed i.e only if condition is getting printed and not the else condition
@rorydaines3176
@rorydaines3176 3 жыл бұрын
@@AmulsAcademy You are seriously amazing, thank you for this.
@jaguargaming1410
@jaguargaming1410 10 ай бұрын
I understood it very well, every step was explained in detailed manner .
@KamalSanjay-
@KamalSanjay- 2 жыл бұрын
There is no words to describe ur explanation, u r excellent sister☺️
@adityan5302
@adityan5302 2 жыл бұрын
Hat's-Off Ma'am, Amazing!! Will remember for life time
@TheMasterswordish
@TheMasterswordish 4 жыл бұрын
Thanks Amul, this helped me enormously.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Glad to hear that!
@thetech685
@thetech685 3 жыл бұрын
very good videos. i am a beginner coder and your tutorials really helped me out!!
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Glad to hear that 😊
@pectenmaximus231
@pectenmaximus231 4 жыл бұрын
Absolutely amazing explanation. So clear. Thanks very much.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Glad it was helpful!
@jathebest2835
@jathebest2835 Жыл бұрын
That was a great explanation..👏 Thank you from Korea!
@digiviewacademy6389
@digiviewacademy6389 2 жыл бұрын
Graet Video.very simple and clear expanation thank you very much
@ArunKumar-il7hv
@ArunKumar-il7hv 10 ай бұрын
Thanks mam your explanation was top notch
@pavithraraji7175
@pavithraraji7175 3 жыл бұрын
The way you explained is awesome 🤩🙌
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you so much 😀
@gokceozkonuk9300
@gokceozkonuk9300 3 жыл бұрын
Thank you very much again for your detailed explaination!
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure ❤️
@kacpermokrzycki2144
@kacpermokrzycki2144 3 жыл бұрын
as a curiosity you can also write def GCD(a,b): return a if b==0 else GCD(b,a%b) if anyone is obsessed with shortcode :))
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
True :)
@jd9452
@jd9452 4 жыл бұрын
WOW, you are so good, Thank You so much for your help.
@saurabhsinghdhami1166
@saurabhsinghdhami1166 4 жыл бұрын
Amazing explanation!!!! And beautiful voice:)
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@happydudhe383
@happydudhe383 2 жыл бұрын
It is a best channel to learn python 🥰
@gonitbuzz
@gonitbuzz 3 жыл бұрын
Amazing tutorial. Take love from Bangladesh 🇧🇩
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@subhashpurushothaman3831
@subhashpurushothaman3831 4 жыл бұрын
Wow...what's that...Your voice is so cute...Of course you explained it perfectly...your voice added more flavor to your explanation skill.......
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@maelonheplorn8893
@maelonheplorn8893 2 жыл бұрын
ngl this comment is creepy as hell
@Fire1nside
@Fire1nside 2 жыл бұрын
@@maelonheplorn8893 yeeah wtf xD
@bikramjitmondal8239
@bikramjitmondal8239 4 жыл бұрын
You got a new subscriber. Great explanation
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@marutikalyan6366
@marutikalyan6366 3 жыл бұрын
Perfect explanation I subscribed ❤️
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@abductingfear1098
@abductingfear1098 3 жыл бұрын
Wow that was me who completed 1k likes on this video Btw you deserve much more than that. Really loved it ❤
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you so much :)
@jyoti3427
@jyoti3427 2 жыл бұрын
Mam thankyou so much for your nice explanation 🙏
@singisbling2500
@singisbling2500 4 жыл бұрын
Great😊 explanation ❤ for your lovely voice 🤗🙏
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thanks a lot 😊
@vinuk540
@vinuk540 4 жыл бұрын
nice and clear explanation,thank you
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@latestupdates6836
@latestupdates6836 2 жыл бұрын
super explained in very simpleway
@HieuNguyen-zj5so
@HieuNguyen-zj5so 3 жыл бұрын
Great explain ... Thank you so much
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
You are welcome! : )
@anthonyfes
@anthonyfes 3 жыл бұрын
Great explanation Mam!
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@balambhavanisankar1924
@balambhavanisankar1924 3 жыл бұрын
I just addicted to ur voice
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@moments_with_frds
@moments_with_frds 2 жыл бұрын
Good explanation 👍👍
@streetnoober4011
@streetnoober4011 7 ай бұрын
Crystal clear....🔮
@saqulainkhan6717
@saqulainkhan6717 2 жыл бұрын
Really great.Thank you🙏🙏
@AmulsAcademy
@AmulsAcademy 2 жыл бұрын
Pleasure 😊
@C.J.JOSEPH
@C.J.JOSEPH 4 жыл бұрын
Ur video contained so much explanation thank u 😘💕
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@kanishkakaushik1868
@kanishkakaushik1868 3 жыл бұрын
Thanks amulya .
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure :)
@mamagrace6208
@mamagrace6208 3 жыл бұрын
Thanks for explaining it so cleary
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
You're welcome! :)
@hashikooshing7411
@hashikooshing7411 3 жыл бұрын
simply amazing individual.....
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@davlatbekkobiljonov911
@davlatbekkobiljonov911 Жыл бұрын
Thank you!!
@Akash-lp1kc
@Akash-lp1kc 4 жыл бұрын
Nice work..
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@sajankumar-ly1tm
@sajankumar-ly1tm 4 жыл бұрын
you are explain perfect ...!!!!!!
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@ambadaschankhore2714
@ambadaschankhore2714 4 жыл бұрын
it's fantastic way to define exact mean of math & Programming concepts ....Really Good for your knowledge & teaching terms.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Thank you :)
@TheDominock
@TheDominock 4 жыл бұрын
I had a terrible stop at this point. Thank you very much.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Welcome :)
@SatendraYadav-cs1yh
@SatendraYadav-cs1yh 4 жыл бұрын
Excellent explain
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Glad it was helpful!
@p.lakshmisairam7220
@p.lakshmisairam7220 Жыл бұрын
ur explanation before writing code is awesome ....is there any paid course of yours i would like to join ...thank you madam
@isharauditha4257
@isharauditha4257 2 жыл бұрын
thank you so much
@komaljaswani7497
@komaljaswani7497 4 жыл бұрын
Hi! Can you please make a video on the question: If a list in python has mix of strings & numbers, how will you make separate lists of strings & numbers? I saw ord() for getting ASCII code in python & chr() for converting ASCII codes to characters somewhere & tried to use them to get answer of this question but it did not work!! :(
@charangummadi6863
@charangummadi6863 3 жыл бұрын
❤️👍👍 well explanation
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊❤️
@csathishsagar516
@csathishsagar516 Жыл бұрын
Sister mi voice tone👌 and good explanation
@zeeshanhussain7213
@zeeshanhussain7213 3 жыл бұрын
Ma'am, You're awesome, Thanks for the video...
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
My pleasure 😊
@zeeshanhussain7213
@zeeshanhussain7213 3 жыл бұрын
Amulya's Academy 🥰😘
@quackthebunny
@quackthebunny 4 жыл бұрын
Great, thanks😇
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
You're welcome 😊
@collinsnwanze8502
@collinsnwanze8502 2 жыл бұрын
Thank you
@MDSHAHABUDDIN-ep4rc
@MDSHAHABUDDIN-ep4rc 3 жыл бұрын
Thanks a lot mam!!
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure 😊
@vijayjakune7409
@vijayjakune7409 3 жыл бұрын
NICE VOICE GREAT EXPLAINATION KEEP IT UP :)
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@manoj7207
@manoj7207 3 жыл бұрын
Thankyou so much
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure :)
@KandhaMaaran-10
@KandhaMaaran-10 3 жыл бұрын
Thankyou so much mam.......
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure :)
@SubhaShini-zd2wt
@SubhaShini-zd2wt 7 ай бұрын
Guys a simple program which you can try for GCD a=int(input ("enter greater no")) b=int(input ("enter smaller no")) while r>0: r=a%b a=b b=r print (a)
@niloyrahman3344
@niloyrahman3344 3 жыл бұрын
great...greater...greatest....programmer...I have ever seen ..take love from me.
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@reshmik4619
@reshmik4619 3 жыл бұрын
Thank you so much mam🤗😁
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Most welcome 😊
@thecoolnewsguy
@thecoolnewsguy 2 жыл бұрын
The easiest method is to divide the greatest number by the second one and then divide the greatest number by numerator of the result. Don't ask me how but it actually works and so efficient 😀
@juliannafotheringham7101
@juliannafotheringham7101 3 жыл бұрын
I love you thank you
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Pleasure :)
@XB-Narsingh
@XB-Narsingh 4 жыл бұрын
gd perfect thank s so much
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Welcome :)
@hiteshchaudhari8698
@hiteshchaudhari8698 3 жыл бұрын
You are awesome mam
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@srisrisridher3597
@srisrisridher3597 2 жыл бұрын
Super mam ❤️
@mahadishakkhor123
@mahadishakkhor123 Жыл бұрын
Thanks
@deadpool4422
@deadpool4422 2 жыл бұрын
Ma'am when i wrote >>> math.gcd(64,48) , you tell it will come 16 but in mines it is 1, can you tell the problem???
@haritika96
@haritika96 5 жыл бұрын
Ma'am mine method for calculating GCD/HCF is correct or not ? Num1 = int(input("Enter the first number : ")) Num2 = int(input("Enter the second number : ")) factors = [] for fact in range(Num1,0,-1): if Num1 % fact == 0 and Num2 % fact == 0: factors.append(fact) print("HCF of ",Num1,"and",Num2,"is : {}".format(max(factors)))
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Yes it will work :) But you didn't check for the smallest input,. when you enter the first value as bigger value, for loop will execute more times than required . The H.C.F can only be less than or equal to the smallest number, so no need to check till bigger number. :)
@jaseerhussain2977
@jaseerhussain2977 3 жыл бұрын
good mam and example more porgramm
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you :)
@satyamsinha1559
@satyamsinha1559 3 жыл бұрын
Uff.. tmhara voice ♥️👌 ..nice explanation though.. very helpful
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thanks a lot 😊
@thuantranvan3164
@thuantranvan3164 4 жыл бұрын
If a and b are complex numbers, how can I find gcd. Please help me
@suryaeagle5516
@suryaeagle5516 4 жыл бұрын
Tq sister excellent explain but I need one program thats are Pascale coding plzz put it....
@264bakshay9
@264bakshay9 3 жыл бұрын
Challa bagundhi
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you 😊
@C.J.JOSEPH
@C.J.JOSEPH 4 жыл бұрын
And what is the algorithm for this gcd program, can u please tell me.
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
Euclid's algorithm :)
@Vishalyadav-ww8ob
@Vishalyadav-ww8ob 3 жыл бұрын
thanks
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Welcome :)
@saicharan3727
@saicharan3727 Жыл бұрын
Nice
@sahukarisidhivinayaka2093
@sahukarisidhivinayaka2093 2 жыл бұрын
Mam in first case i.e 4%18 you got 4. Can you please explain how did you get that?
@HarshitaChattopadhyay
@HarshitaChattopadhyay 4 жыл бұрын
Mam can u pls do LCM of 2 numbers programs pls...
@astrovishwalingam7299
@astrovishwalingam7299 4 жыл бұрын
Your voice is so cute thanks for you
@vikashvinod3936
@vikashvinod3936 2 жыл бұрын
Mam , how did it run multiple times in function call?
@AarthifTechBuild
@AarthifTechBuild 6 жыл бұрын
Hello Amulus,Thank You for the video you did on GCD I will always recommend you to my friend for your wonderful teaching And amulus just a small request apart from the GCD programme you did can u also do a video on Conversion from Hexadecimal to decimal it's a bottom hearted request pls do it for me
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Sure:)
@AarthifTechBuild
@AarthifTechBuild 6 жыл бұрын
Amuls Academy Amulus when can u do this video for me
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Next week:)
@shotokproductions9162
@shotokproductions9162 5 жыл бұрын
Hi Amulya how to develop logics like this and did each program logic needs base and recursive cases
@linkmageful
@linkmageful 5 жыл бұрын
is that the recursive code?
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
No you can write program without recursion also(iterative approach). But for some problems using recursion is best choice because of its simplicity. There are many articles on "how to think recursively in python". You can refer that. :)
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Yes:) @linkmageful
@shotokproductions9162
@shotokproductions9162 5 жыл бұрын
will it possible to have all your code in mail?
@veeraregalla2460
@veeraregalla2460 3 жыл бұрын
Explain how to read values seperated by comma
@dharshinimagesh9591
@dharshinimagesh9591 4 жыл бұрын
mam ,pl explain this hi mam , i understand this program but according to the if "loop" it should get the values " 2,3 or 4" as GCD coz it divides 48,36 equally how it gets 12 as GCD . n1 = 48 n2 = 36 #find smaller if(n1>n2): smaller = n2 else: smaller = n1 #getting hcf i = 1 while(i
@AmulsAcademy
@AmulsAcademy 4 жыл бұрын
greatest common divisor of 48 and 36 is 12. common divisor of 48 and 36 is 1 2 3 4 6 12 In this greatest is 12 so GCD is 12. In the program while loop will run until i
@dharshinimagesh9591
@dharshinimagesh9591 4 жыл бұрын
@@AmulsAcademy oh ok . i got it now 😃. thank u very much mam .
@linkmageful
@linkmageful 5 жыл бұрын
is this the recursive form?
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Yes:)
@pradumnyarokade9935
@pradumnyarokade9935 5 жыл бұрын
Ma'am how 2 find Gcd of big no. As like 3997 & 2947
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
I think you are asking manually how to find out the gcd of bigger numbers. There are some mathematical shortcuts you need search that, you can google it. :)
@ambujkhanduri5672
@ambujkhanduri5672 5 жыл бұрын
How to make a program to find the LCM And how to make a program to find the second lowest numbers from given n numbers.
@ramkuncha3380
@ramkuncha3380 6 жыл бұрын
if I take 3 values . it will execute or not.your explanation is super. sister I will give input in string and I want output into numbers .you will execute this programme
@pradeepchauhan9184
@pradeepchauhan9184 6 жыл бұрын
Good teaching....
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
for three values you need to use reduce, import functools def gcd(a,b): if(b==0): return a else: return gcd(b,a%b) a=int(input("Enter first number:")) b=int(input("Enter second number:")) c=int(input(":")) GCD=functools.reduce(gcd,(a,b,c)) print("GCD is: ") print(GCD) :)
@AmulsAcademy
@AmulsAcademy 6 жыл бұрын
Thank you:)
@theegreatestever2420
@theegreatestever2420 2 жыл бұрын
Had to watch the last part a few times but damn thank you so much cause now I get it! Solving some Python Basic challenges from W3R schools and didnt really get this one...TILL NOW 😊😊🤣🤣😉😎😎
@SumitKumar-ti4yf
@SumitKumar-ti4yf 5 жыл бұрын
Why it is not necessary to mention a>b....How a%b works in this program even when a
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
when i take a= 4 b = 18 then here we can see a here we can see value is interchanged. first value becomes 18 and second value becomes 4, then it will execute the function. so no need to check whether a is greater then b or not :)
@newtonkumar6741
@newtonkumar6741 3 жыл бұрын
subscribed..reallly u are amazing
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Thank you so much 😀
@karanpreetsinghsekhon8076
@karanpreetsinghsekhon8076 4 жыл бұрын
Great but I have do this with list so how I do that
@infinitygaming7192
@infinitygaming7192 2 жыл бұрын
I have a easy method we can do like this we put statemnt if num1%i ==0 and num2%i ==0 Then we will set range to (0,smallernum) And add this to a new list and last number will always be largest number so we will return lis[-1]
@somyachawla5422
@somyachawla5422 3 жыл бұрын
What if we remove return statement from ComputeGCD
@AmulsAcademy
@AmulsAcademy 3 жыл бұрын
Try :)
@praneethaluru2601
@praneethaluru2601 4 жыл бұрын
list1=[] list2=[] for i in range(2,n1): if n1%i==0: print(i, end=',') list1.append(i) print(" ") for j in range(2,n2): if n2%j==0: print(j, end=',') list2.append(j) list3=[] for i in list1: for j in list2: if i==j: list3.append(i) print("HCF is",max(list3)) Is this ok?
@mdfarhan0203
@mdfarhan0203 3 жыл бұрын
def gcd_function(a,b): big=max(a,b) small=min(a,b) # print(big) # print(small) reminder=big%small while reminder!=0: big=small small=reminder reminder=big%small print(small) number=10 number1=20 print(gcd_function(number,number1))
@srikanthchittampally3398
@srikanthchittampally3398 4 жыл бұрын
How the program runs without using loop
@kvnagendra5354
@kvnagendra5354 5 жыл бұрын
*I don't know ur name but tq yaar 💝💝*
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Pleasure :) My name is Amulya.
@eswarisangeetha3730
@eswarisangeetha3730 5 жыл бұрын
Give a detail information about merge sort sister
@AmulsAcademy
@AmulsAcademy 5 жыл бұрын
Sure:)
@eswarisangeetha3730
@eswarisangeetha3730 5 жыл бұрын
Thq sis
Guess The Output | Python Programs and Answers
2:20
Amulya's Academy
Рет қаралды 35 М.
Program To Calculate LCM Of Two Numbers | Python Tutorials
19:20
Amulya's Academy
Рет қаралды 61 М.
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 19 МЛН
WHO LAUGHS LAST LAUGHS BEST 😎 #comedy
00:18
HaHaWhat
Рет қаралды 19 МЛН
Solve any Star Pattern program in Python
18:44
Simply Coding
Рет қаралды 874 М.
GCD - Euclidean Algorithm (Method 1)
14:38
Neso Academy
Рет қаралды 514 М.
Python - Greatest Common Divisor W/ Recursion
9:14
Wrt Tech
Рет қаралды 8 М.
Python Tutorial - Fibonacci Series
13:49
Amulya's Academy
Рет қаралды 183 М.
Leap Year Program | Python Tutorials
12:12
Amulya's Academy
Рет қаралды 75 М.
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 430 М.
Python Tutorial - Prime Numbers | Printing Prime Numbers in Given Interval
18:33
If __name__ == "__main__" for Python Developers
8:47
Python Simplified
Рет қаралды 385 М.
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 19 МЛН