Tuesday, 19 June 2018

Tribonacci Series Generation


For visual follow https://youtu.be/kso7dWX8_fg
Fibonacci series – adding the two successive numbers and store.
1+2+3+5+8+13 and so on

The logic is c = a + b  
                  A             B
1    +         2       +     3 +       5  +        8+      13
A                 B             C
and above alphabets replaced with lower alphabets as explained below.
C holds the answer for next loop the a and b should be changed to next value as shown in the below figure
Step 1: perform addition of A and B. Store the result in C.
Step 2: change the value of A to B and B to C (above alphabets write on left side and below alphaets write on write side)
Step 3: Put step 1 and step 2 inside a for loop and execute the loop based on user requirement. 

Tribonacci series – adding the three successive numbers and store
                  A             B           C
1    +         2       +     3 +       6  +        11+      20 + 37 and so on
A                 B             C          D
Step 1: perform addition of A , B and C. Store the result in D.
Step 2: change the value of C to D, B to C, A to B (above alphabets write on left side and below alphaets write on write side)
Step 3: Put step 1 and step 2 inside a for loop and execute the loop based on user requirement. 




Subscribe to my channel!

No comments:

Post a Comment