src/Alg/Math/Prime.php
public static function getPrimeFactors( $number, $list = array() )
	{
		Deprecation::getInstance()
			->setErrorVersion( '0.8.5' )
			->setExceptionVersion( '0.9' )
			->message( sprintf(
				'Please use %s (%s) instead',
				'public library "CeusMedia/Math"',
			 	'https://packagist.org/packages/ceus-media/math'
			) );
		$edge	= floor( sqrt( $number ) );
		$primes	= self::getPrimes( $edge );
		if( self::isPrime( $number ) )
		{
			$list[] = $number;
		}
		else if( count( $primes ) )
		{
			rsort( $primes );
			foreach( $primes as $prime )
			{
				if( $number % $prime == 0 )
				{
					$tmp = $list;
					$tmp[] = $prime;
					$rest = $number / $prime;
					$result = self::getPrimeFactors( $rest, $tmp );
					if( count( $result ) )
					{
						sort( $result );
						return $result;
					}
				}
			}
		}
		return $list;
	}
public static function getPrimeFactors( $number, $list = array() )
	{
		Deprecation::getInstance()
			->setErrorVersion( '0.8.5' )
			->setExceptionVersion( '0.9' )
			->message( sprintf(
				'Please use %s (%s) instead',
				'public library "CeusMedia/Math"',
			 	'https://packagist.org/packages/ceus-media/math'
			) );
		$edge	= floor( sqrt( $number ) );
		$primes	= self::getPrimes( $edge );
		if( self::isPrime( $number ) )
		{
			$list[] = $number;
		}
		else if( count( $primes ) )
		{
			rsort( $primes );
			foreach( $primes as $prime )
			{
				if( $number % $prime == 0 )
				{
					$tmp = $list;
					$tmp[] = $prime;
					$rest = $number / $prime;
					$result = self::getPrimeFactors( $rest, $tmp );
					if( count( $result ) )
					{
						sort( $result );
						return $result;
					}
				}
			}
		}
		return $list;
	}
public static function getPrimeFactors ( $ number , $ list = array ( ) ) { Deprecation :: getInstance ( ) -> setErrorVersion ( '0.8.5' ) -> setExceptionVersion ( '0.9' ) -> message ( sprintf ( 'Please use %s (%s) instead' , 'public library "CeusMedia/Math"' , 'https://packagist.org/packages/ceus-media/math' ) ) ; $ edge = floor ( sqrt ( $ number ) ) ; $ primes = self :: getPrimes ( $ edge ) ; if ( self :: isPrime ( $ number ) ) { $ list [ ] = $ number ; } else if ( count ( $ primes ) ) { rsort ( $ primes ) ; foreach ( $ primes as $ prime ) { if ( $ number % $ prime == 0 ) { $ tmp = $ list ; $ tmp [ ] = $ prime ; $ rest = $ number / $ prime ; $ result = self :: getPrimeFactors ( $ rest , $ tmp ) ; if ( count ( $ result ) ) { sort ( $ result ) ; return $ result ; } } } } return $ list ; }
Returns a List of Prime Factors if given Number is dividable with Prime Numbers.
@access		public
@static
@param		int			$number
@param		array		$list
@return		array
Returns a List of Prime Factors if given Number is dividable with Prime Numbers .