How to write a program for fibonacci series using perl?

Can someone help me in writing program for fibonacci series using perl..

Questions by kutta20

Showing Answers 1 - 3 of 3 Answers

Pavithra

  • Jun 29th, 2015
 

Code
  1. #!usr/bin/local/perl

  2. $n=<>;

  3. $f= 0;

  4. $s = 1;

  5. for ( $i = 0 ; $i < $n ; $i++ )

  6. {

  7. if($i<= 1 )

  8. {

  9. $next=$i;

  10. }

  11. else

  12. {

  13. $next = $f + $s;

  14. $f = $s;

  15. $s = $next;

  16. }

  17. print(" the fibonacci series:$next

  18. ");

  19. }

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions