Revision: 43254
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 20, 2011 06:48 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 total:Number = 10;
var primeArr:Array = new Array();
public function init():void{
var num:Number = total+1;
var str:String;
var i:Number=3;
do{
if(primeNumber(i) == true)
{
primeArr.push(i);
}
i++;
}while(primeArr.length<10)
for(var j=0;j<primeArr.length;j++){
txt.text += "\n "+primeArr[j];
}
}
function primeNumber(num):Boolean
{
var bool:Boolean;
var nums = Math.floor(Math.sqrt(num));
var i:Number = 1;
bool = true;
while (++i <= nums) {
if ((num % i) == 0) {
bool = false;
i = nums;
}
}
return bool;
}
]]>
</mx:Script>
<mx:TextArea x="118" y="57" width="553" height="412" id="txt"/>
</mx:Application>
Initial URL
Initial Description
Looking forward for the most optimized solution
Initial Title
1st 10 prime numbers OR check whether a number is prime or not
Initial Tags
actionscript, flash, Flex
Initial Language
ActionScript 3