PHPBuilder - Prime factorization



RSS Twitter
Snippets Math Functions

Prime factorization

by: Hkon Brten
|
May 14, 2008

Version: 1

Type: Function

Category: Math Functions

License: GNU General Public License

Description: Factorizes a given number



<?
function factorize ($number) {
	for ($i=2; $i < $number; $i++) {
		if (0 == ($number % $i)) {
			$factors[] = $i;
			$number = $number / $i;
			$i = 1;
		}
	}
	$factors[] = $number;
	return $factors;
}
?>

Comment and Contribute

Your comment has been submitted and is pending approval.

Author:
Hkon Brten

Comment:



Comment:

(Maximum characters: 1200). You have characters left.