I didn’t understand how should I print the pattern for this fibonacci series .
Heyyyyy , I need doubt assistance to print the fibonacci triangle
hi @deepshreyamishra301_1918130c8477386b,
In Pattern Question, there is a common method which we teach in course viz, taking nsp, nst, csp, cst and row variables.
Pattern Hack : Always first Try to first print pattern by ignoring the value to be printed then accommodate your value in that pattern. For e.g.,
0
1 1
2 3 5
8 13 21 34
View it as:-
*
* *
* * *
* * * *
``
`` Short Info about the variables:-
1. nsp (number of spaces)-> Number of spaces in very First Line of the pattern.
2. nst (number of stars)-> Number of stars in very first line of the pattern.
3. csp (counter of spaces)-> counter of spaces that will print the required number of spaces and will be initialized with 1 and incremented upto nsp.
4. cst (counter of stars)-> counter of spaces that will print the required number of stars and will be initialized with 1 and incremented upto nst.
5. rows -> It will be initialized with 1 and will go upto the total number of rows in the pattern.
In Given, pattern no spaces are there only stars are present.
nst = 1, cst = 1, rows = 1, total rows = n;
The Fibonacci numbers are the numbers in the following integer sequence. 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ………
In this sequence a fibonacci number is calculated as sum of the previous two fibonacci numbers.Here 0th fibonacci is 0 and 1stfibonacci is 1.
In the given pattern each number is separated from other by a tab. For given input n, You need to print n(n+1)/2 fibonacci numbers i.e. Kth row contains , next k fibonacci numbers.
refer here :