«

»

MathEx Class, Math and Statistic Function

The MathEx class is extended from PrimeFactor class. This class have more math calculation function like finding Arithmetic, Geometric sequences, more than two numbers for LCM and GCD, and some statistics function. The MathEx will be update for more math and statistic function. See AS3Doc for more detail about methods and properties.

Credits:

AS3Doc
MathEx (70)

Find LCM and GCD of numbers

package
{
	import com.irzal.MathEx;
	import flash.display.Sprite;

    public class Main extends Sprite
    {
		public function Main()
		{
			trace("LCM:", MathEx.lcm(10, 20, 30, 40, 50, 60, 70, 80, 90));
			trace("GCD:", MathEx.gcd(10, 20, 30, 40, 50));
		}
	}
}

//output
//LCM: 25200
//GCD: 10

Find Standard Deviation and Variance Population

package
{
	import com.irzal.MathEx;
	import flash.display.Sprite;

    public class Main extends Sprite
    {
		public function Main()
		{
			trace("Standard Deviation Population:", MathEx.statistic.stdDevPop(10, 20, 30, 40, 50, 60, 70, 80, 90));
			trace("Variance Population:", MathEx.statistic.variancePop(10, 20, 30, 40, 50));
		}
	}
}

//output
//Standard Deviation Population: 25.81988897471611
//Variance Population: 200

Create an array of arithmetic sequence, triangle number and pascal triangle

package
{
	import com.irzal.MathEx;
	import flash.display.Sprite;

    public class Main extends Sprite
    {
		public function Main()
		{
			trace("Arithmetic sequence:",MathEx.arithSeq(5, 2, 10));
			trace("Tringale Number start form 6th index:",MathEx.triNum(6, 10));
			trace("10th row of pascal triangle:",MathEx.nPascalTri(10));
		}
	}
}

//output
//Arithmetic sequence: 5,7,9,11,13,15,17,19,21,23
//Tringale Number start form 6th index: 21,28,36,45,55,66,78,91,105,120
//10th row of pascal triangle: 1,10,45,120,210,252,210,120,45,10,1

Leave a Reply

Your email address will not be published.

*