素数を数えて落ち着く
素数カウント
/**
* Copyright keno42 ( http://wonderfl.net/user/keno42 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/6Bfr
*/
// 素数カウント
package {
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.Event;
public class FlashTest extends Sprite {
private var tf:TextField = new TextField();
private var list1:Vector.<uint> = new Vector.<uint>();
private var list2:Vector.<uint> = new Vector.<uint>();
private var index:int = 2;
public function FlashTest() {
// write as3 code here..
addChild(tf);
tf.autoSize = "left";
tf.width = 465;
tf.wordWrap = true;
tf.text = "1,";
for( var i:int = 0; i < 10000; i++ ){
onEnterFrame(null);
}
//addEventListener("enterFrame", onEnterFrame);
}
private function onEnterFrame(e:Event):void{
var count1:uint = list1.length;
for( var i:uint = 0; i < count1; i++ ) {
list2[i]++;
if( list2[i] == list1[i] ){
list2[i] = 0;
break;
}
}
if( i == count1 ){
list1.push(index);
list2.push(0);
tf.appendText( index + "," );
}
for( i=i+1; i < count1; i++ ) {
list2[i]++;
if( list2[i] == list1[i] ){
list2[i] = 0;
}
}
index++;
}
}
}