Recursions & Recursive Functions in C++ | C++ Tutorials for Beginners #18

  Рет қаралды 559,946

CodeWithHarry

CodeWithHarry

Күн бұрын

Пікірлер: 658
@harmankaur3938
@harmankaur3938 2 жыл бұрын
//Author:Harman kaur //purpose:fibonacii series #include using namespace std; int fib(int n) { if (n < 2) { return 1; } else { return fib(n - 1) + fib(n - 2); } } int main() { int num; cout num; cout
@Bloodflood
@Bloodflood 6 ай бұрын
what will be the iterative approach he is mentioning is it with the help of loops
@saeedahmedjamali7235
@saeedahmedjamali7235 4 ай бұрын
Thank you! Needed this for an assignment
@GeekyShubhamSharma
@GeekyShubhamSharma 5 жыл бұрын
N(N-1)! = Katai jahar concept bilkul sahi paaji😂😁 dedo ♥️♥️♥️♥️♥️♥️
@nirmalbuoy
@nirmalbuoy 4 жыл бұрын
12th maths padhi hoti toh tujhe zeher nhi lagta ekdum basic hai ye
@palashagrawal2343
@palashagrawal2343 4 жыл бұрын
@@nirmalbuoy 11th maths be
@nirmalbuoy
@nirmalbuoy 4 жыл бұрын
@@palashagrawal2343 Ha wahi jo bhi hai, hume JEE coaching ke waqt aisa kuch 11th 12th nahi padhaya tha isiliye pata nahi kaunse class me aata hai
@crazygirls2862
@crazygirls2862 3 жыл бұрын
11th maths Padhi nahi hai aapne bca wale ho na
@iamFJ18
@iamFJ18 3 жыл бұрын
Halwa hai😂😂
@iSubhoo
@iSubhoo 4 жыл бұрын
Sir, jab samajh me awajata hay, to video ending song bohat acha lagtahay.
@khatariinsaan5284
@khatariinsaan5284 3 жыл бұрын
7:55 what a clear Explanation
@tcoa79_rajdange62
@tcoa79_rajdange62 3 жыл бұрын
Legendary 😃
@aaryanmehta981
@aaryanmehta981 3 жыл бұрын
Can you give practice uestions after every lecture
@AnEngineerHuman
@AnEngineerHuman 2 жыл бұрын
Loving this playlist. Day-12 Completed upto Tutorial-18 Date-14/12/2022 Time-19:32 Topic-Recursions and Recursive Functions
@sayman099
@sayman099 2 жыл бұрын
bro are u from cs / it branch?
@AnEngineerHuman
@AnEngineerHuman 2 жыл бұрын
@@sayman099 yes bro,i am from it branch.
@pratikingle3963
@pratikingle3963 Жыл бұрын
@@AnEngineerHuman CPP DONE???
@pratikingle3963
@pratikingle3963 Жыл бұрын
@@sayman099 TUM KONSE BRANCH SE HOO??
@AnEngineerHuman
@AnEngineerHuman Жыл бұрын
@@pratikingle3963 ha ,keh sakte ho .Par jada practise nahi hui... Thanks for reminding me
@rudranshsharma114
@rudranshsharma114 2 ай бұрын
Giving some question that You can practice 1)Write a program which displays the largest among 2 No. 2)Write a program which displays grade on basis of marks 3)Find the roots of quadratic equation 4) To find year enter by user is a leap year or not 5)To find operation of 2 No. enter by the user by (Switch) method{+,-,*,%,/)etc. 6)To find operation of 2 No. enter by the user by (if else ladder) method 7) using goto feature create a multiplicative table 8)Sum of digit of integer enter by user by (goto) statement{EX- 76 = 13} 9) Sum of n natural numbers using (for) statement 10)To Find factors of No. enter by user 11)To find to Reverse of Digit 12)To state whether no. enter is Penedrom or not 13)To find No. is prime or composite Agar inke code cheye to message me . Please Pin this student ki help hogi bhot isse ache questions hain
@arnavmaheshwari6149
@arnavmaheshwari6149 3 жыл бұрын
I realized something that all the people who are watching this to learn c++ are building there programming style a lot similar to harry bhai's
@apmotivationakashparmar722
@apmotivationakashparmar722 2 жыл бұрын
fib(5)=fib(4) + fib(3) = fib(2) + fib(3) + fib(2) + fib(1) should in place of fib(2) + fib(3) + fib(2) + fib(3).
@rohitashwapratapsingh142
@rohitashwapratapsingh142 2 жыл бұрын
yes
@anju7334
@anju7334 2 жыл бұрын
Ye chij mujhe samaj ni aayi ki Harry bro ne kaise toda Could you pleas explain me?
@apmotivationakashparmar722
@apmotivationakashparmar722 2 жыл бұрын
fib(n) = fib(n-1) + fib(n-2) apply this .
@anju7334
@anju7334 2 жыл бұрын
@@apmotivationakashparmar722 n = 5 so fib(5) = fib(4) + fib(3) ho gya But iske bad ye dubara se jab run hoga to fib(4) ke liye fib(4-2) = fib(2) Fib(4-1) = fib(3) And fib(3) ke lye fib (3-1) = fib(2) Fib(3-2) = fib(1) Banega but lecture me fib(1) to kahi hai hi nhi
@anupamdatta6584
@anupamdatta6584 Жыл бұрын
​@@anju7334 Jab fib(1) meh jayega toh value toh 1 return karega kyuki n
@Abhishek-dp5tc
@Abhishek-dp5tc 4 жыл бұрын
competitive programming pe series bana bhai, Please!
@SK-gp6cm
@SK-gp6cm 2 жыл бұрын
Do you find cp series???
@Abhishek-dp5tc
@Abhishek-dp5tc 2 жыл бұрын
@@SK-gp6cm wow 2 years back Yes many series are there, I also bought a course on udemy but it is more of DSA focused rather than cp
@SK-gp6cm
@SK-gp6cm 2 жыл бұрын
@@Abhishek-dp5tc can you share that link
@Ramneet04
@Ramneet04 2 жыл бұрын
Bro where can i practice question or should i practice question or first complete whole series of c++ here
@gulshansingh7961
@gulshansingh7961 2 жыл бұрын
@@Ramneet04 first complete this series
@rajanijaiswal333
@rajanijaiswal333 5 жыл бұрын
Awesome video Question of 03:00 yess
@30vaibhavdhaygondexdr.v.sa22
@30vaibhavdhaygondexdr.v.sa22 4 жыл бұрын
3:06 ----> this is correct
@nishtha9666
@nishtha9666 3 жыл бұрын
Ur explanation is Just amazing👍👍👍👍👍The Best
@b10gaming2
@b10gaming2 4 жыл бұрын
I can't even imagine a world without stack overflow and codewithharry!
@seasonalmind7241
@seasonalmind7241 3 жыл бұрын
can u tell me how 2 returned in fibbonacci at 3?
@desiquant
@desiquant 3 жыл бұрын
@@seasonalmind7241 f(3) = f(2)+f(1) = [f(1)+f(0)] + f(1) = f(0) + 2 f(1) = 1 + 2(1) = 1+2 = 3. Makes sense?
@seasonalmind7241
@seasonalmind7241 3 жыл бұрын
@@desiquant yeah it definitely does.Thanks.
@unknownsuperstarmanish7013
@unknownsuperstarmanish7013 2 жыл бұрын
increase u r imagination
@bhuwannath61
@bhuwannath61 2 жыл бұрын
2:52 n! = n*(n-1)! It is correct . Let we take example : Factorial of 5 = 5×4x3x2x1 . Instead of multiplying like above we should first calculate factorial of 4 and then multiply it with 5 . Now we get factorial of 5.
@programinglife.1400
@programinglife.1400 2 жыл бұрын
Hme bhi ata hai
@nitishkr75
@nitishkr75 2 жыл бұрын
@@programinglife.1400 😂😂
@yashodharpatel6594
@yashodharpatel6594 4 жыл бұрын
We can also do this by using Array, It decreases the execution time. 1. Factorial : int fact(int n){ int a[100]; a[0] = 0, a[1] = 1, a[2] = 2; for(int i = 3;i
@ayushparmar7729
@ayushparmar7729 3 жыл бұрын
bhaiya is factorial wale tarike se aur harry bhaiya ke tarike se bhi 20! ka ans nhi aa rha ans negative m de deta h koi solution is ko solve krne ka for greater integer values
@kartikbisht1909
@kartikbisht1909 Жыл бұрын
@@ayushparmar7729 20 ka factorial?
@kartikbisht1909
@kartikbisht1909 Жыл бұрын
@@ayushparmar7729 bhai 20 ka factorial itna badha hota h ki int mi nhi aa sakta kyuki int ki range -2147483648 to 2147483647 hoti h aur iska factorial quadrillion mei h
@ayushparmar7729
@ayushparmar7729 Жыл бұрын
@@kartikbisht1909 bhai vo to ho gya tha jo bhi digit calculate krke aa rhi h use array m store krte joa aur pos pointer ko +1 krte jao
@kartikbisht1909
@kartikbisht1909 Жыл бұрын
@@ayushparmar7729 ook
@satyamsharma8371
@satyamsharma8371 3 ай бұрын
Superb... 👍👍👍
@Ishika-n9g
@Ishika-n9g Жыл бұрын
11:42 if(n
@indrocky6530
@indrocky6530 5 ай бұрын
In the fib function, the base case returns 1 for n
@kiranshinde03
@kiranshinde03 3 жыл бұрын
3:08 yes Harry Bhai we can write.
@syeduzairmohiuddin5514
@syeduzairmohiuddin5514 2 жыл бұрын
👍👍👏Excellent explanation.
@chaolobi7698
@chaolobi7698 2 жыл бұрын
thanks harry bro
@karanbisht-k6k
@karanbisht-k6k Жыл бұрын
Iterative approach for fibonacci. #include using namespace std; void fibonacci(int n){ int a =0; int b=1; int sum =0; cout
@AbhrajyotiDas-l7h
@AbhrajyotiDas-l7h Жыл бұрын
While calculating the factorial of very big number, we get zero since computers try to give the answer in exponential form. So, to get the actual result, change the data type of the function to double to get the exact value. Hope this helps!
@AnushkaPandey-h2c
@AnushkaPandey-h2c Жыл бұрын
Actually, I wanted to calculate the factorial of 100 but it gave 0 as an answer...I was confused. But because of your advice, I changed int to double and I got the correct answer. Thank You!
@AbhrajyotiDas-l7h
@AbhrajyotiDas-l7h Жыл бұрын
@@AnushkaPandey-h2c Happy to know that the solution I gave, helped somebody :) ! This made my day :)
@Sports-im6yv
@Sports-im6yv Жыл бұрын
Bhai datatype long used karke dekh
@bansilalnabediya3501
@bansilalnabediya3501 Жыл бұрын
​@@Sports-im6yveven better long double😊
@Sports-im6yv
@Sports-im6yv Жыл бұрын
@@bansilalnabediya3501 thanks bhai ❤
@HiTech1203
@HiTech1203 4 жыл бұрын
You have made my coding life easy
@akashwaghmare7221
@akashwaghmare7221 2 жыл бұрын
You are the most intelligent programmer in the India
@AbcD-ju9un
@AbcD-ju9un Ай бұрын
JazakAllah sir Ameen.
@vijaysurve4700
@vijaysurve4700 3 жыл бұрын
Teaching method is awesome👍👏
@royfamily9273
@royfamily9273 3 жыл бұрын
Yes, n!=n*(n-1)!. Thanks Harry Bhaiya
@saqlainali8401
@saqlainali8401 Жыл бұрын
Wasa ap boht amazing ho sar manna padaga he is so amazing apki explanation to ItnA excellent ha ka na bhi samajh aya to ap samjha hi data han ItnA àcha aj tak mujha kisii na koi topic nhi samjhaya you are the best for explained every topic thank you so much sir thanks
@pikachugaming3371
@pikachugaming3371 2 жыл бұрын
You are same like my sir very understanding
@YashPatil-t8c
@YashPatil-t8c 2 ай бұрын
If a = 5, the program calculates the fifth term in the Fibonacci sequence using the recursive calls: fibonacci(5) is called. Since a > 2, it goes to fibonacci(5) = fibonacci(3) + fibonacci(4). To solve fibonacci(3), it breaks down further: fibonacci(3) = fibonacci(1) + fibonacci(2). Both fibonacci(1) and fibonacci(2) return 1, so fibonacci(3) = 1 + 1 = 2. Meanwhile, for fibonacci(4): fibonacci(4) = fibonacci(2) + fibonacci(3). fibonacci(2) returns 1. fibonacci(3), as calculated earlier, is 2. Thus, fibonacci(4) = 1 + 2 = 3. Now, substituting back, fibonacci(5) = fibonacci(3) + fibonacci(4) = 2 + 3 = 5.
@AhmadJamil-kk1on
@AhmadJamil-kk1on Ай бұрын
Yes you can Because if you take 7 as n then n-1 will be 6, when we take the fictorial of 6 then absolutely get the desired ans
@harshitjain2081
@harshitjain2081 4 жыл бұрын
2:55 Yes it is factorial
@abuhuraira5293
@abuhuraira5293 2 жыл бұрын
recursions means a function is calling itself on its own until it gets the answer
@akshanshkaushal9422
@akshanshkaushal9422 2 жыл бұрын
16:00 It should be like this. Fib(3)= Fib(2)+Fib(1)...correct me if I'm wrong.
@janakkore1597
@janakkore1597 2 жыл бұрын
I think you are right since I was searching for this comment as well
@kumkumbhagya51
@kumkumbhagya51 2 жыл бұрын
2:51 sahi hoga kyuki yahi formula hai factorial nikaalne ka
@anees_05
@anees_05 Жыл бұрын
fib(5) // fib(4) + fib(3) // fib(2) + fib(3) + fib(2) + fib(3) harry bhai ap ne is mai ghalti krdi hai mai tou cinfused hogaya tha pehle ab clear hogaya
@satyamkarn3277
@satyamkarn3277 3 жыл бұрын
3:07 yes you can write.
@akashwaghmare7221
@akashwaghmare7221 2 жыл бұрын
Your teaching is awesome
@khizrshaikh9902
@khizrshaikh9902 3 жыл бұрын
2:46 Yes It is correct ye baat sahi hongi
@fellincode2607
@fellincode2607 3 жыл бұрын
finally mere ko recursion samajh me aagaya mene java playlist me ek baar video dekha to mere ko utna samajh me nahi mene dusri baar dekhna ka socha procasination hoto gayi!
@MayureshYadav-xf1ii
@MayureshYadav-xf1ii 2 ай бұрын
Thank you so much sir
@atifmalik8012
@atifmalik8012 6 ай бұрын
#include using namespace std; int factorial(int n){ if(n==0||n==1){ return 1; } else{ return n*factorial(n-1); } } int main(){ int n; cout
@gaganagrawal8194
@gaganagrawal8194 3 жыл бұрын
Sir please provide practice questions also
@anshitshukla7498
@anshitshukla7498 5 жыл бұрын
Data structures aur algorithm pe playlist 🙏🙏🙏🙏
@nikhilraj1842
@nikhilraj1842 5 жыл бұрын
go to geeksforgeeks until codewithharry sir upload Data structures and algorithms
@anshitshukla7498
@anshitshukla7498 5 жыл бұрын
@@nikhilraj1842 thanks
@niteshbovi769
@niteshbovi769 3 жыл бұрын
@@nikhilraj1842 can u plz tell me the roadmap for programming language with dsa
@nikhilraj1842
@nikhilraj1842 3 жыл бұрын
@@niteshbovi769 well i am not a professional in this topic as I learned which i like to do in dsa like question solving and I Don't follow a roadmap. So i can't give you roadmap for this.
@alnahian8051
@alnahian8051 2 жыл бұрын
3:08 yes it can be written
@kunalkumar6783
@kunalkumar6783 3 жыл бұрын
IN last 16:30 - I will see you next time...... BGM(totally incredible)
@sagar_wani
@sagar_wani 3 жыл бұрын
Thank Harry 😊
@kundanpatidar9207
@kundanpatidar9207 4 жыл бұрын
Love these content
@sanatandharmyogicculture700
@sanatandharmyogicculture700 3 жыл бұрын
Teaching method is awesome
@chiragparmar1964
@chiragparmar1964 2 жыл бұрын
I really love all of your videos BUT please change your chrome browser theme to DARK MODE because when you switch from vs code to chrome browser it hurt my eyes badly because we are so focused on your video and suddenly going from black screen to white screen really hurt eye cornea and I cant tolerate that feeling anymore please take this note on a serious measure...btw love your teaching style and keep it on!
@rashidhashmi6181
@rashidhashmi6181 Жыл бұрын
yes u can it as factorial✅
@deepikasoni4833
@deepikasoni4833 11 ай бұрын
Thankyou so much sir🙏🏻😁
@tayyab.sheikh
@tayyab.sheikh Жыл бұрын
Now i understand kay India ka har bacha coder kyuon hai.
@nishumittal4277
@nishumittal4277 2 жыл бұрын
yes, we write n*(n-1) to the n!
@riddhimapradhan84
@riddhimapradhan84 2 жыл бұрын
Well explained🙌🙌
@laxman2919
@laxman2919 2 жыл бұрын
HARRY NAAM SE HARRY POTTER SMJHE KYA , PRO CODER H ME 😍😍😍💥💥💥💥💥💥
@gurpreetsingh-jh3bk
@gurpreetsingh-jh3bk 4 жыл бұрын
thank you sir
@studytostudy5919
@studytostudy5919 2 жыл бұрын
Ha likh sakte hai 😀👍🏻....
@SamarthChawlaSam
@SamarthChawlaSam 5 ай бұрын
1:32 6! = 720 2:52 Sahi hogi
@SouravBiswal-hh5iw
@SouravBiswal-hh5iw 6 ай бұрын
Yes thk haie..❤
@usefullyuseless4404
@usefullyuseless4404 3 жыл бұрын
i want to call you and will say that... HAA BHAI ACCESSS KARLI HAI PLAYLIST!!!!! KARLI HAIIIIII !!!!!!!!!!!!!!
@hitsong5606
@hitsong5606 Жыл бұрын
sani bat hai
@iSubhoo
@iSubhoo 4 жыл бұрын
Yes Sir, n! = n * (n-1)!
@ashitranjan3971
@ashitranjan3971 Жыл бұрын
Well enjoying the tutorial
@codingislit1404
@codingislit1404 3 жыл бұрын
Thanks bhaiya
@sajidamehrosh505
@sajidamehrosh505 3 жыл бұрын
Sir you make programing easy for me really thank you SSO much.....
@AbhishekKumar-id3yz
@AbhishekKumar-id3yz 3 жыл бұрын
Fibonacci Series 0 se start hota hai. 12:46 par n sahi tha. Aapne 1 kar diya anways bade bade sahro me chotti chotti baat hote rahti hai
@jawadmalik6832
@jawadmalik6832 Жыл бұрын
we can also find factorial using static as in previous video.
@DhvanitMonpara
@DhvanitMonpara Жыл бұрын
How? I tried but it isn't possible without recursion or looping.
@muhammadareebkazmi9476
@muhammadareebkazmi9476 2 жыл бұрын
Thank you, Harry bhai!
@kumkumbhagya51
@kumkumbhagya51 2 жыл бұрын
bro pls practice set bana do us se aur bhi zyada confidence aa jaata hai jab saare questions complete krleta hu
@varshithkumark983
@varshithkumark983 10 ай бұрын
12:57 for n
@MrUKD4444
@MrUKD4444 4 ай бұрын
yes ❤
@harkishannarola4223
@harkishannarola4223 2 жыл бұрын
#include using namespace std; int work(int n){ if(n>=30){ return n = 3; } else if(n>=15){ return n = 4; } else if(n>=10){ return n = 5; } else if(n>=5){ return n = 6; } return n = 8; } int main(){ int a; cout
@manavroy7293
@manavroy7293 3 жыл бұрын
3:06 Yes.
@mr_amit_shelke
@mr_amit_shelke Жыл бұрын
3:11 Yes, Ofcourse
@hibbonix9530
@hibbonix9530 2 жыл бұрын
Muje bohot achhe se samj aa gaya thank you sir 😭😭😭
@satyaanand9243
@satyaanand9243 2 жыл бұрын
toh ro kyu rahe ho?
@hibbonix9530
@hibbonix9530 2 жыл бұрын
@@satyaanand9243 hay tum bhi dsa sikh rahe ho kay?? Please reply karna
@Rizwankhan-dh5xh
@Rizwankhan-dh5xh 4 жыл бұрын
make a complete course on data structure and algorithum please sir
@anonymousgerman2809
@anonymousgerman2809 3 жыл бұрын
Thankyou harry bhai
@VoyagerDevSharma
@VoyagerDevSharma 3 жыл бұрын
Definitely sir we can write it
@DaniyalSaqib-my1us
@DaniyalSaqib-my1us 10 ай бұрын
Recursion is just a function calling itself inside itself
@cheryrj8305
@cheryrj8305 Жыл бұрын
thnk u soo much for this, its really helpful for me
@angshumandasgupta4857
@angshumandasgupta4857 2 жыл бұрын
yes you are right
@srijansoni6972
@srijansoni6972 2 жыл бұрын
Completed ✅❣️🔥
@Lifeinspiration7777
@Lifeinspiration7777 Жыл бұрын
recursion means function call itself again an again until result is found
@mansipansuriya5917
@mansipansuriya5917 2 жыл бұрын
true hai
@saqlainali8401
@saqlainali8401 Жыл бұрын
You are the best
@internetenjoyer9186
@internetenjoyer9186 2 жыл бұрын
For calculation nth term we can use a+(n-1)d, where a is 1st term and d is common difference
@ananyasingh774
@ananyasingh774 2 жыл бұрын
that's for constant series, but here the common difference is changing
@Life.Z1
@Life.Z1 Жыл бұрын
Ha..it is the staple equation where the difference is fixed
@hopes_alive-100
@hopes_alive-100 3 жыл бұрын
3:06 yes! likh sakte hai
@maheshkumarpatel5790
@maheshkumarpatel5790 4 жыл бұрын
yes n*(n-1) is true!!
@saadhassan8813
@saadhassan8813 8 ай бұрын
good teacher
@runwithrahul
@runwithrahul Жыл бұрын
#include using namespace std; int fib(int n){ if (n
@newsend257
@newsend257 Жыл бұрын
time 2:53 Yes , ture , n! = n * ( n -1)
@abhijitsingh855
@abhijitsingh855 4 жыл бұрын
Thanxxx bhaiya...it helped a lot...😇
@Sousa2255
@Sousa2255 2 жыл бұрын
3:05 Obviously sir
@hassaandzigns
@hassaandzigns Жыл бұрын
gg Sir bilkul Likh skty hain
@maygirl4086
@maygirl4086 3 жыл бұрын
yes we can write it tthat way
@HarshRaj-pi4om
@HarshRaj-pi4om 3 жыл бұрын
bhaiya thanku for your help!
@engineeringlife4567
@engineeringlife4567 3 жыл бұрын
Sir , ye video enough h ya fir particle exercise bhi karni padegi
Recursion Tutorial - Basics to Advanced | Part 1
46:22
Apna College
Рет қаралды 62 М.
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 62 МЛН
How Strong Is Tape?
00:24
Stokes Twins
Рет қаралды 96 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
C_104 Recursion in C | Introduction to Recursion
18:51
Jenny's Lectures CS IT
Рет қаралды 473 М.
Learn Coding & Get a Job (in 2025) 🔥
16:54
CodeWithHarry
Рет қаралды 563 М.
8 Data Structures Every Programmer Should Know
17:09
ForrestKnight
Рет қаралды 241 М.
31 nooby C++ habits you need to ditch
16:18
mCoding
Рет қаралды 851 М.
Starting Competitive Programming - Steps and Mistakes
9:55
William Lin (tmwilliamlin168)
Рет қаралды 1,4 МЛН
Pointers in C++ | C++ Tutorials for Beginners #12
16:39
CodeWithHarry
Рет қаралды 1 МЛН
Recursive Functions: Recursion In C: C Tutorial In Hindi #21
25:47
CodeWithHarry
Рет қаралды 696 М.