Saved Bookmarks
| 1. |
Design an algorithm to generate nth member of the Fibonacci sequence. |
|
Answer» An algorithm to generate nth member of Fibonacci sequence is: 1. start 2. Scan the number ‘n’ upto which the series to be generated. 3. Initialize Sum=0, x=0, y=1 and i=3. 4. Print x and y as the part of series. 5. Repeat a-e until i<=n a. Calculate Sum=x+y b. Print Sum as part of series. c. Assign y to x d. Assign sum to y e. i=i+1 6. Stop. |
|