A. 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 mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation.
Fn = F n-1 + F n-2
B. Factorial of a non-negative integer, is multiplication of all integers smaller than or equal to n. For example, factorial of 6 is 6*5*4*3*2*1 which is 720.
n! = n * (n - 1) * …….. 1
A)
START
Step 1 Declare variables A, B, C,n
Step 2 Set A = 0, B = 0
Step 3 DISPLAY A, B
Step 4 C = A + B
Step 5 DISPLAY C
Step 6 Set A = B, B = C
Step 7 REPEAT from 4 - 6, for n times
STOP
B)
Start
Step 1: Declare variables n, fact, i
Step 2: Read number from User
Step 3: Initialize variables fact=1 and i=1
Step 4: Repeat Until i<=number
4.1 fact=fact*i
4.2 i=i+1
Step 5: Print fact
Stop
Comments
Leave a comment