It's possible to generalize many of the recurrence relations (that we come across in Combinatorics problems, (you may want to try recurrence relations problems like these )
And if you want to know some tricks to manipulate things come to homogeneous recurrences, see the solutions in my note Need help
This was for in Maths... Let's now try programming..... (I have just started learning it...)
In programming(Python), people try various programs to print the numbers, but what i prefer is , start with an empty list " "
Then, we write a program which will take into consideration all the Fibonacci numbers.
As shown in the image, just the to , so the is now containing the terms of Fibonacci Sequence!!!
On this list, as shown you can do operations like of elements (use sum(li) ), of elements (use len(li), which gives length of list 'li'), and the code can be used to see whether any given number is a term of a Fibonacci sequence or not. (If the number is in Fibonacci sequence, then will give value 1, and else, 0 )
This will be for the terms of Fibonacci sequence which are less than the range you type at first. (in the while loop)
Also, not only Fibonacci sequence, you can get other recurrence relations by this too !
Like the one in terms , like initial conditions and for , This type of recurrences, you can solve by making characteristic equation and finding it's roots, as done in this note.
But by programming, it will be as follows
In this one, the recurrence is simply defined by the last line in the loop. Then, the list will directly get numbers included and you can try any operations, like sum of first terms, or you can even find the term of the sequence just by using python code and it will give you the term. (Note that it won't give general form, it will give value for value of ).
Because this was example, i restricted the range of , but you may try to get bigger values by increasing it !
This shows the use of Programming to get terms of a recurrence relation and easily doing operations on them, like addition of few, for example, if you want the sum of terms to of Fibonacci sequence (i.e. , where is Finbonacci term), then you define a new list as and it will make to be list of Fibonacci numbers from to . (Note that in new list, we took in formula for li_1 because it will exclude 2nd term)
Like and reshare if it was helpful to you.