Return to Snippet

Revision: 43255
at March 20, 2011 07:10 by kanuwadhwa


Initial Code
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init()">
	<mx:Script>
		<![CDATA[
			var num:Number = 10;
			public function init():void{
				factor(num);
				txt.text = factor(num).toString();
			}
			
			public function factor(num:Number):Number{
				var mul:Number = 1;
				for(var i=2;i<=num;i++){
					mul *= i;
					txt.text += "\n >>"+mul;
				}
				return mul;
			}
		]]>
	</mx:Script>
	<mx:TextArea x="118" y="57" width="553" height="412" id="txt"/>
</mx:Application>

Initial URL

                                

Initial Description
Looking forward for more optimized solution for the same

Initial Title
Factorial of a number

Initial Tags
actionscript, flash, Flex

Initial Language
ActionScript 3