«

»

Find GCD, LCM and Prime Factor Using PrimeFactor Class

The PrimeFactor class can find GCD, LCM prime factor of GCD and LCM, prime factor of a number, and one additional method that could create an array of prime numbers.

To find prime factor of a number use of method

import com.irzal.PrimeFactor;

trace("Prime factor of 90:",PrimeFactor.of(90));
//output
Prime factor of 90: 2,3,3,5

to find gcd of numbers use gcd method

import com.irzal.PrimeFactor;
trace("GCD of 12, 36, 90:",PrimeFactor.gcd(12, 36, 90));
//output
GCD of 12, 36, 90: 6

To find gcd prime factor of numbers use gcdPrime method

import com.irzal.PrimeFactor;

trace("GCD of 12, 36, 90:",PrimeFactor.gcdPrime(12, 36, 90));

//output
GCD of 12, 36, 90: 2,3

To find LCM of numbers use lcm method

import com.irzal.PrimeFactor;

trace("LCM of 12, 36, 90:", PrimeFactor.lcm(12, 36, 90));
//output
LCM of 12, 36, 90: 180

To find LCM prime factor of numbers use lcmPrime method

import com.irzal.PrimeFactor;

trace("LCM of 12, 36, 90, 70:",PrimeFactor.lcmPrime(12, 36, 90,70));
//output
LCM of 12, 36, 90, 70: 2,2,3,3,5,7

PrimeFactor
PrimeFactor AS3Doc

[update]
for more math function see MathEx class

Leave a Reply

Your email address will not be published.

*