I am not able to pass all test cases and also don’t know how to code for only one input
Fibonacci pattern hackers block
@Ayushi21
I could not find the exact problem that you are trying here. It would be helpful if you could give me the exact name or the hackerblocks link for the problem since there are several problems having Fibonacci in their name.
I believe you are trying to print a simple Fibonacci sequence and if its just that then the first change you need to make is change the data type to long long int as Fibonacci series grows extremely fast and crosses the range of int very quickly.
After that put up conditions for inputs like 1 or 2.
If the input is 1 , then your code should only print 0 and not anymore.
Your rest of the code seems fine.
the problem name is fibonacci pattern(pattern 4)
@Ayushi21
When you are trying to print patterns of such kind having multiple rows and columns , you need to use two nested loops.
The outer loop controls the behaviour of total no of rows whereas the inner loop controls the behaviour of each specific row.
As for the single input , the input defines the maximum no of rows and columns that we are supposed to reach.
So try something like this
for(int i=1;i <= row;i++) {
for(int j=1 ; j <=i ; j++) {
----
}
}
You have to figure out the inner working as to what would happen inside the body of the loop.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.