Algorithm to generate fibonacci series upto N terms.

1. Start.
2. Initialize first_term = 0 ,
                  second_term = 1 ,
                  print_term = 1 ,
                  count = 0 .
3. Read value of N.
4. If N >= 1, print first_term and increment count by 1.
5. If N >= 2, print second_term and increment count by 1.
6. While count <= N,
               print_term = first_term + second_term ;
               first_term = second_term;
               second_term = print_term;
               Print print_term.
               Increment value of count by 1.
7. End.

No comments:

Post a Comment