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

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 648

  • @aaryanmehta981
    @aaryanmehta981 3 года назад +95

    Can you give practice uestions after every lecture

  • @GeekyShubhamSharma
    @GeekyShubhamSharma 4 года назад +114

    N(N-1)! = Katai jahar concept bilkul sahi paaji😂😁
    dedo ♥️♥️♥️♥️♥️♥️

    • @nirmalbuoy
      @nirmalbuoy 4 года назад +36

      12th maths padhi hoti toh tujhe zeher nhi lagta ekdum basic hai ye

    • @palashagrawal2343
      @palashagrawal2343 3 года назад +12

      @@nirmalbuoy 11th maths be

    • @nirmalbuoy
      @nirmalbuoy 3 года назад +1

      @@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 года назад +6

      11th maths Padhi nahi hai aapne bca wale ho na

    • @iamFJ18
      @iamFJ18 3 года назад +1

      Halwa hai😂😂

  • @iSubhoo
    @iSubhoo 3 года назад +22

    Sir, jab samajh me awajata hay, to video ending song bohat acha lagtahay.

  • @apmotivationakashparmar722
    @apmotivationakashparmar722 2 года назад +78

    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 года назад +1

      yes

    • @anju7334
      @anju7334 Год назад +4

      Ye chij mujhe samaj ni aayi ki Harry bro ne kaise toda
      Could you pleas explain me?

    • @apmotivationakashparmar722
      @apmotivationakashparmar722 Год назад +3

      fib(n) = fib(n-1) + fib(n-2) apply this .

    • @anju7334
      @anju7334 Год назад +4

      @@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

  • @harmankaur3938
    @harmankaur3938 2 года назад +33

    //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 4 месяца назад

      what will be the iterative approach he is mentioning is it with the help of loops

    • @saeedahmedjamali7235
      @saeedahmedjamali7235 Месяц назад

      Thank you! Needed this for an assignment

  • @Abhishek-dp5tc
    @Abhishek-dp5tc 4 года назад +130

    competitive programming pe series bana bhai, Please!

    • @SK-gp6cm
      @SK-gp6cm 2 года назад +3

      Do you find cp series???

    • @Abhishek-dp5tc
      @Abhishek-dp5tc 2 года назад +3

      @@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 года назад +2

      @@Abhishek-dp5tc can you share that link

    • @Ramneet04
      @Ramneet04 2 года назад +2

      Bro where can i practice question or should i practice question or first complete whole series of c++ here

    • @gulshansingh7961
      @gulshansingh7961 2 года назад +4

      @@Ramneet04 first complete this series

  • @AnEngineerHuman
    @AnEngineerHuman Год назад +31

    Loving this playlist.
    Day-12
    Completed upto Tutorial-18
    Date-14/12/2022
    Time-19:32
    Topic-Recursions and Recursive Functions

    • @sayman099
      @sayman099 Год назад

      bro are u from cs / it branch?

    • @AnEngineerHuman
      @AnEngineerHuman Год назад +1

      @@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

  • @khatariinsaan5284
    @khatariinsaan5284 3 года назад +13

    7:55 what a clear Explanation

  • @30vaibhavdhaygondexdr.v.sa22
    @30vaibhavdhaygondexdr.v.sa22 4 года назад +7

    3:06 ----> this is correct

  • @Ishika-n9g
    @Ishika-n9g Год назад +12

    11:42 if(n

  • @nishtha9666
    @nishtha9666 2 года назад +9

    Ur explanation is Just amazing👍👍👍👍👍The Best

  • @b10gaming2
    @b10gaming2 3 года назад +133

    I can't even imagine a world without stack overflow and codewithharry!

    • @seasonalmind7241
      @seasonalmind7241 3 года назад +6

      can u tell me how 2 returned in fibbonacci at 3?

    • @desiquant
      @desiquant 3 года назад +10

      @@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 года назад +5

      @@desiquant yeah it definitely does.Thanks.

    • @unknownsuperstarmanish7013
      @unknownsuperstarmanish7013 2 года назад +1

      increase u r imagination

  • @indrocky6530
    @indrocky6530 3 месяца назад +1

    In the fib function, the base case returns 1 for n

  • @AbhrajyotiDas-l7h
    @AbhrajyotiDas-l7h Год назад +26

    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 Год назад +3

      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 Год назад +3

      @@AnushkaPandey-h2c Happy to know that the solution I gave, helped somebody :) ! This made my day :)

    • @Sports-im6yv
      @Sports-im6yv Год назад +1

      Bhai datatype long used karke dekh

    • @bansilalnabediya3501
      @bansilalnabediya3501 Год назад

      ​@@Sports-im6yveven better long double😊

    • @Sports-im6yv
      @Sports-im6yv Год назад +1

      @@bansilalnabediya3501 thanks bhai ❤

  • @yashodharpatel6594
    @yashodharpatel6594 4 года назад +18

    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

  • @bhuwannath61
    @bhuwannath61 2 года назад +16

    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.

  • @rajanijaiswal333
    @rajanijaiswal333 4 года назад +7

    Awesome video
    Question of 03:00
    yess

  • @arnavmaheshwari6149
    @arnavmaheshwari6149 3 года назад +30

    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

  • @HiTech1203
    @HiTech1203 3 года назад +8

    You have made my coding life easy

  • @satyamsharma8371
    @satyamsharma8371 Месяц назад +1

    Superb... 👍👍👍

  • @syeduzairmohiuddin5514
    @syeduzairmohiuddin5514 2 года назад +6

    👍👍👏Excellent explanation.

  • @akshanshkaushal9422
    @akshanshkaushal9422 2 года назад +4

    16:00 It should be like this. Fib(3)= Fib(2)+Fib(1)...correct me if I'm wrong.

    • @janakkore1597
      @janakkore1597 Год назад

      I think you are right since I was searching for this comment as well

  • @rudranshsharma114
    @rudranshsharma114 8 дней назад

    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

  • @gaganagrawal8194
    @gaganagrawal8194 3 года назад +6

    Sir please provide practice questions also

  • @jawadmalik6832
    @jawadmalik6832 11 месяцев назад +3

    we can also find factorial using static as in previous video.

    • @DhvanitMonpara
      @DhvanitMonpara 9 месяцев назад

      How? I tried but it isn't possible without recursion or looping.

  • @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

  • @Rizwankhan-dh5xh
    @Rizwankhan-dh5xh 3 года назад +11

    make a complete course on data structure and algorithum
    please sir

    • @sanatani_raj462
      @sanatani_raj462 2 года назад

      Already there on channel bro 😃😃

    • @biswadarshee3660
      @biswadarshee3660 2 года назад

      @@sanatani_raj462 Tu 10 mahine baad reply karega ...toh woh bana liya hoga naa ????

  • @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

  • @akashwaghmare7221
    @akashwaghmare7221 2 года назад

    You are the most intelligent programmer in the India

  • @kiranshinde03
    @kiranshinde03 3 года назад +2

    3:08 yes Harry Bhai we can write.

  • @abuhuraira5293
    @abuhuraira5293 2 года назад +6

    recursions means a function is calling itself on its own until it gets the answer

  • @royfamily9273
    @royfamily9273 2 года назад +1

    Yes, n!=n*(n-1)!.
    Thanks Harry Bhaiya

  • @pikachugaming3371
    @pikachugaming3371 2 года назад +1

    You are same like my sir very understanding

  • @vijaysurve4700
    @vijaysurve4700 3 года назад +1

    Teaching method is awesome👍👏

  • @kumkumbhagya51
    @kumkumbhagya51 2 года назад +1

    bro pls practice set bana do us se aur bhi zyada confidence aa jaata hai jab saare questions complete krleta hu

  • @nishumittal4277
    @nishumittal4277 2 года назад +1

    yes, we write n*(n-1) to the n!

  • @kundanpatidar9207
    @kundanpatidar9207 4 года назад +6

    Love these content

  • @internetenjoyer9186
    @internetenjoyer9186 2 года назад +9

    For calculation nth term we can use a+(n-1)d, where a is 1st term and d is common difference

    • @ananyasingh774
      @ananyasingh774 2 года назад +3

      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

  • @satyamkarn3277
    @satyamkarn3277 2 года назад +1

    3:07 yes you can write.

  • @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

  • @harshitjain2081
    @harshitjain2081 3 года назад +1

    2:55 Yes it is factorial

  • @sajidamehrosh505
    @sajidamehrosh505 3 года назад +7

    Sir you make programing easy for me really thank you SSO much.....

  • @kunalkumar6783
    @kunalkumar6783 2 года назад +1

    IN last 16:30 - I will see you next time...... BGM(totally incredible)

  • @kumkumbhagya51
    @kumkumbhagya51 Год назад +1

    2:51 sahi hoga kyuki yahi formula hai factorial nikaalne ka

  • @akashwaghmare7221
    @akashwaghmare7221 2 года назад

    Your teaching is awesome

  • @ashitranjan3971
    @ashitranjan3971 Год назад

    Well enjoying the tutorial

  • @alnahian8051
    @alnahian8051 2 года назад

    3:08 yes it can be written

  • @anshitshukla7498
    @anshitshukla7498 4 года назад +19

    Data structures aur algorithm pe playlist 🙏🙏🙏🙏

    • @nikhilraj1842
      @nikhilraj1842 4 года назад +3

      go to geeksforgeeks until codewithharry sir upload Data structures and algorithms

    • @anshitshukla7498
      @anshitshukla7498 4 года назад

      @@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.

  • @BlackScreenProductions
    @BlackScreenProductions 2 года назад +2

    Write a C ++ Program. We have a day-to-day record of USD price in PKR for last 100 weeks. Find the week, which has a highest variation in PKR, while a base price is 160Rs = 1 USD. Also, find which week has the highest average USDprice
    Sir Please Solve The Problem

  • @varshithkumark8993
    @varshithkumark8993 7 месяцев назад

    12:57 for n

  • @kunalshahare9041
    @kunalshahare9041 3 года назад +1

    thanks bhai

  • @Lifeinspiration7777
    @Lifeinspiration7777 11 месяцев назад +1

    recursion means function call itself again an again until result is found

  • @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!

  • @Ravi_477
    @Ravi_477 2 года назад +1

    Bhai Competitive Programming pr series banao please

  • @AdityaGupta-cz7wp
    @AdityaGupta-cz7wp 4 года назад +5

    recursion function is also known as aatmnirbhar function

  • @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

  • @rashidhashmi6181
    @rashidhashmi6181 Год назад

    yes u can it as factorial✅

  • @sanatandharmyogicculture700
    @sanatandharmyogicculture700 2 года назад

    Teaching method is awesome

  • @sagar_wani
    @sagar_wani 2 года назад

    Thank Harry 😊

  • @saadhassan8813
    @saadhassan8813 5 месяцев назад

    good teacher

  • @DaniyalSaqib-my1us
    @DaniyalSaqib-my1us 7 месяцев назад

    Recursion is just a function calling itself inside itself

  • @hopes_alive-100
    @hopes_alive-100 2 года назад

    3:06 yes! likh sakte hai

  • @07670
    @07670 2 года назад +6

    Your way of teaching is really awesome . But I have one request can u plz written program separately , sometime it's confusing and irritating too...

  • @chiragparmar1964
    @chiragparmar1964 2 года назад +1

    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!

  • @gurpreetsingh-jh3bk
    @gurpreetsingh-jh3bk 3 года назад +1

    thank you sir

  • @jaydeepsatani6878
    @jaydeepsatani6878 2 года назад +1

    yes likh sakte hai

  • @manavroy7293
    @manavroy7293 2 года назад +1

    3:06
    Yes.

  • @muhammadareebkazmi9476
    @muhammadareebkazmi9476 2 года назад

    Thank you, Harry bhai!

  • @lawprakashguptaiitk5132
    @lawprakashguptaiitk5132 2 года назад

    Thank you Harry bro

  • @cheryrj8305
    @cheryrj8305 Год назад

    thnk u soo much for this, its really helpful for me

  • @chaolobi7698
    @chaolobi7698 2 года назад

    thanks harry bro

  • @shumailabatool7493
    @shumailabatool7493 3 года назад

    Yes we can write n*(n-1)!

  • @abhishekchoudhary1204
    @abhishekchoudhary1204 3 года назад

    yes we can

  • @angshumandasgupta4857
    @angshumandasgupta4857 2 года назад

    yes you are right

  • @papaajanpapa4281
    @papaajanpapa4281 Год назад

    Yes true Hogi n!

  • @gameforall_official
    @gameforall_official 3 года назад

    It will be
    If(n

  • @saqlainali8401
    @saqlainali8401 Год назад

    You are the best

  • @iSubhoo
    @iSubhoo 3 года назад +1

    Yes Sir, n! = n * (n-1)!

  • @chinmaykhairnar6750
    @chinmaykhairnar6750 2 года назад

    Yes we can write 3:07

  • @mukulnayak2452
    @mukulnayak2452 4 года назад +2

    Upload a video on factorial of large numbers like 100 and more.

  • @khizrshaikh9902
    @khizrshaikh9902 3 года назад

    2:46
    Yes It is correct
    ye baat sahi hongi

  • @avanishchaurasiya9190
    @avanishchaurasiya9190 2 года назад +1

    3:05 yes

  • @sea604
    @sea604 3 года назад +1

    सही बात है।

  • @salmanahmadkhan4417
    @salmanahmadkhan4417 2 года назад

    yes we can write it

  • @harshhitgupta4434
    @harshhitgupta4434 3 месяца назад

    bilkul sahi baat hogi

  • @deepikasoni4833
    @deepikasoni4833 8 месяцев назад

    Thankyou so much sir🙏🏻😁

  • @engineeringlife4567
    @engineeringlife4567 2 года назад +1

    Sir , ye video enough h ya fir particle exercise bhi karni padegi

  • @maygirl4086
    @maygirl4086 3 года назад

    yes we can write it tthat way

  • @Techmaster-qp2ut
    @Techmaster-qp2ut 4 года назад +6

    Best Explination Sir, Very Nice Video

  • @SouravBiswal-hh5iw
    @SouravBiswal-hh5iw 4 месяца назад

    Yes thk haie..❤

  • @studytostudy5919
    @studytostudy5919 2 года назад

    Ha likh sakte hai 😀👍🏻....

  • @umangkumar1756
    @umangkumar1756 Год назад

    we can write factorial n *(n-1)

  • @hibbonix9530
    @hibbonix9530 Год назад +1

    Muje bohot achhe se samj aa gaya thank you sir 😭😭😭

    • @satyaanand9243
      @satyaanand9243 Год назад

      toh ro kyu rahe ho?

    • @hibbonix9530
      @hibbonix9530 Год назад

      @@satyaanand9243 hay tum bhi dsa sikh rahe ho kay?? Please reply karna

  • @pratyushkurhe1577
    @pratyushkurhe1577 2 года назад

    3:07 yes we can

  • @vanitascarte9949
    @vanitascarte9949 2 года назад

    Harry Bhaiya competitive programming ka bhi course nikaliye

  • @Sousa2255
    @Sousa2255 2 года назад

    3:05 Obviously sir

  • @newsend257
    @newsend257 Год назад

    time 2:53
    Yes , ture , n! = n * ( n -1)

  • @MrUKD4444
    @MrUKD4444 2 месяца назад

    yes ❤

  • @techahsan1873
    @techahsan1873 2 года назад

    yes likh sakty hain (n-1)

  • @jawadbilal5557
    @jawadbilal5557 2 месяца назад

    Yesh we can write