Fibonacci Series


/ Published in: ActionScript 3
Save to your folder(s)

Looking forward for the most optimized solution for the same


Copy this code and paste it in your HTML
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
  3. <mx:Script>
  4. <![CDATA[
  5. // 0,1,1,2,3,5,8,13
  6. public function init():void{
  7. var a:Number = 0;
  8. var b:Number = 1;
  9. txt.text = a.toString();
  10. txt.text += "\n"+b;
  11. for(var i:int=2;i<10;i++){
  12. var c:Number = a+b;
  13. a = b;
  14. b = c;
  15. txt.text += "\n"+c;
  16. }
  17. }
  18. ]]>
  19. </mx:Script>
  20. <mx:TextArea x="118" y="57" width="553" height="412" id="txt"/>
  21. </mx:Application>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.