Algorithm For Sum of Digits and Fibonacci Series
Algorithm For Sum of Digits and Fibonacci Series
1. Start
2. Read n
3. Consider the variables sum and count
3.1 Initialize sum=0
4. Check if n /= 0
4.1 If yes
4.2 Calculate count = n % 10
4.3 Calculate sum = sum + count
4.4 Determine value of n as n = n/10
4.5 If no
4.6 Go to step 6
READ Initialize
STAR
n sum = 0
T
Determine n as
n = n/10 LOOP
Print sum
Stop
Algorithm for Fibonacci Series.
1. Start
2. Read n
3. Consider two variables a, b
3.1 Initialize values of a = 0 and b = 1
4. Print a, b
5. Let “c” is a variable initialized to 0
6. While n > 0
7. c = a + b
8. print c
9. a=b
10. b=c
11. n = n-1
12. Repeat steps from 6 to 11 until n==0
13. stop
Let a=0
START Read n
b=0
If Yes If No
Print c c=a+b If n>0
a=b
n = n-1
b=c LOOP
Stop