@@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
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.
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
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
@@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
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
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!
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!
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.
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
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
@@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.
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!
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!
#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
// factorial of n #include using namespace std; int factorial (int n){ if (n==1||n==0){ return 1; } int factorialNm1=factorial(n-1); int factN=factorialNm1*n; return factN; } int main(){ int n; coutn; cout
//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
what will be the iterative approach he is mentioning is it with the help of loops
Thank you! Needed this for an assignment
Can you give practice uestions after every lecture
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).
yes
Ye chij mujhe samaj ni aayi ki Harry bro ne kaise toda
Could you pleas explain me?
fib(n) = fib(n-1) + fib(n-2) apply this .
@@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
@@anju7334 Jab fib(1) meh jayega toh value toh 1 return karega kyuki n
N(N-1)! = Katai jahar concept bilkul sahi paaji😂😁
dedo ♥️♥️♥️♥️♥️♥️
12th maths padhi hoti toh tujhe zeher nhi lagta ekdum basic hai ye
@@nirmalbuoy 11th maths be
@@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
11th maths Padhi nahi hai aapne bca wale ho na
Halwa hai😂😂
7:55 what a clear Explanation
Legendary 😃
Sir, jab samajh me awajata hay, to video ending song bohat acha lagtahay.
competitive programming pe series bana bhai, Please!
Do you find cp series???
@@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
@@Abhishek-dp5tc can you share that link
Bro where can i practice question or should i practice question or first complete whole series of c++ here
@@Ramneet04 first complete this series
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.
Loving this playlist.
Day-12
Completed upto Tutorial-18
Date-14/12/2022
Time-19:32
Topic-Recursions and Recursive Functions
bro are u from cs / it branch?
@@sayman099 yes bro,i am from it branch.
@@AnEngineerHuman CPP DONE???
@@sayman099 TUM KONSE BRANCH SE HOO??
@@pratikingle3963 ha ,keh sakte ho .Par jada practise nahi hui...
Thanks for reminding me
11:42 if(n
3:06 ----> this is correct
In the fib function, the base case returns 1 for n
Ur explanation is Just amazing👍👍👍👍👍The Best
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
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
@@ayushparmar7729 20 ka factorial?
@@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
@@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
@@ayushparmar7729 ook
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
I can't even imagine a world without stack overflow and codewithharry!
can u tell me how 2 returned in fibbonacci at 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?
@@desiquant yeah it definitely does.Thanks.
increase u r imagination
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
Awesome video
Question of 03:00
yess
3:08 yes Harry Bhai we can write.
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!
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!
@@AnushkaPandey-h2c Happy to know that the solution I gave, helped somebody :) ! This made my day :)
Bhai datatype long used karke dekh
@@Sports-im6yveven better long double😊
@@bansilalnabediya3501 thanks bhai ❤
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.
Hme bhi ata hai
@@programinglife.1400 😂😂
You have made my coding life easy
Iterative approach for fibonacci.
#include
using namespace std;
void fibonacci(int n){
int a =0;
int b=1;
int sum =0;
cout
#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
👍👍👏Excellent explanation.
16:00 It should be like this. Fib(3)= Fib(2)+Fib(1)...correct me if I'm wrong.
I think you are right since I was searching for this comment as well
You are same like my sir very understanding
Yes, n!=n*(n-1)!.
Thanks Harry Bhaiya
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
You are the most intelligent programmer in the India
we can also find factorial using static as in previous video.
How? I tried but it isn't possible without recursion or looping.
recursion means function call itself again an again until result is found
yes, we write n*(n-1) to the n!
Superb... 👍👍👍
Teaching method is awesome👍👏
IN last 16:30 - I will see you next time...... BGM(totally incredible)
recursions means a function is calling itself on its own until it gets the answer
Sir please provide practice questions also
2:51 sahi hoga kyuki yahi formula hai factorial nikaalne ka
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
Your teaching is awesome
2:55 Yes it is factorial
Sir you make programing easy for me really thank you SSO much.....
Now i understand kay India ka har bacha coder kyuon hai.
Data structures aur algorithm pe playlist 🙏🙏🙏🙏
go to geeksforgeeks until codewithharry sir upload Data structures and algorithms
@@nikhilraj1842 thanks
@@nikhilraj1842 can u plz tell me the roadmap for programming language with dsa
@@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.
12:57 for n
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!
Recursion is just a function calling itself inside itself
3:07 yes you can write.
Thank you so much sir
1:32 6! = 720
2:52 Sahi hogi
2:46
Yes It is correct
ye baat sahi hongi
make a complete course on data structure and algorithum
please sir
#include
#include
using namespace std;
void fibonacci_sequence(int );
int main()
{
int n;
coutn;
fibonacci_sequence(n);
return 0;
}
void fibonacci_sequence(int n)
{
int a=-1 ,b=1 ,i, sum , N=20;
cout
Best Explination Sir, Very Nice Video
For calculation nth term we can use a+(n-1)d, where a is 1st term and d is common difference
that's for constant series, but here the common difference is changing
Ha..it is the staple equation where the difference is fixed
bro pls practice set bana do us se aur bhi zyada confidence aa jaata hai jab saare questions complete krleta hu
3:08 yes it can be written
Love these content
Teaching method is awesome
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!
#include
using namespace std;
int fib(int n){
if (n
we can write factorial n *(n-1)
Bhai Competitive Programming pr series banao please
It will be
If(n
yes you are correct
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
recursion function is also known as aatmnirbhar function
oooo
thanks harry bro
Well enjoying the tutorial
#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
Yes we can write n*(n-1)!
thank you sir
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...
yeah even I felt the same
Yes Sir, n! = n * (n-1)!
3:05 Obviously sir
yes u can it as factorial✅
// factorial of n
#include
using namespace std;
int factorial (int n){
if (n==1||n==0){
return 1;
}
int factorialNm1=factorial(n-1);
int factN=factorialNm1*n;
return factN;
}
int main(){
int n;
coutn;
cout
Thank you, Harry bhai!
int getNthFib(int n) // without recursion using iterative method
{
if (n == 1)
{
return 0;
}
else if(n == 2)
{
return 1;
}
else
{
int prevPrev = 0;
int prev = 1;
int currentNumber;
for (int i = 2; i
sir please make some practice sets also likke python course
3:06
Yes.
Harry Bhaiya competitive programming ka bhi course nikaliye
Muje bohot achhe se samj aa gaya thank you sir 😭😭😭
toh ro kyu rahe ho?
@@satyaanand9243 hay tum bhi dsa sikh rahe ho kay?? Please reply karna
Thankyou so much sir🙏🏻😁
Please make the DataStructure videos
thnk u soo much for this, its really helpful for me
Thanks bhaiya
yes we can write it tthat way
3:06 yes! likh sakte hai
Yest n*(n-1)we can write for n!
i want to call you and will say that...
HAA BHAI ACCESSS KARLI HAI PLAYLIST!!!!! KARLI HAIIIIII !!!!!!!!!!!!!!
14:39 fib(3) will break in fib(3) + fib(1)
i suppose u meant fib(3) will break in fib(2) + fib(1)
good teacher
# same function in python
def factorial(x):
if x
But very slow as compared to cpp if you run it it will take 5-7 sec but in cpp even more lines of code will run under 2 sec
But code is wrong💯💯
time 2:53
Yes , ture , n! = n * ( n -1)
14:36 last line of fib comment correction -- fib(2) + fib(3) + fib(1) + fib(2)
Thank Harry 😊
yes you are right
Yes, We can write n! = n*(n-1)!
Definitely sir we can write it