PHP Classes

PHP Find Prime Factors: Get the prime factors of a number upto 100 billion

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 72%Total: 251 All time: 7,911 This week: 560Up
Version License PHP version Categories
prime-factors 1.0Free for non-comm...4.0Algorithms, Math


This class can get the prime factors of a number upto 100 billion.

It takes a number and decomposes it into factor numbers that are prime.

The class returns the prime factors in an array variable. Optionally it can output all the prime factors as it finds them.

It uses a data file to extract the lowest prime factors faster.

Picture of Abhishek Shukla
  Performance   Level  
Name: Abhishek Shukla <contact>
Classes: 5 packages by
Country: India India
Age: ???
All time rank: 65640 in India India
Week rank: 286 Up17 in India India Up


<title>Prime Factors</title>
<body style="background-color:#0CCCCC;">
<h1>Prime Factors</h1>
//Test of prime factorization class by abhishek shukla


$test=new prime_factors;


//test for getting factors as array
echo "<br/>Factors of 1024 =".implode(",",$factors);
echo "<br/>Factors of 13 =".implode(",",$factors);
if(count($factors)==1)echo " (prime).";




///////////////////////////////////////////////////////////////////////////////////// // // Class Prime Factors // It finds factors of whole numbers upto 100 Billion very fast and accurate // using a pre-existing data set. // (C) ABHISHEK SHUKLA // Date Created : Jan 13, 2016 // Last Modified: // Version 1.00 // This Software Should not be commercially used without prior and // explicit permission of the Author // ///////////////////////////////////////////////////////////////////////////////////// Usage is very simple 1) Include class script file include("primefactors.php"); 2) Initiate a new object of class prime_factors $test=new prime_factors; 3) Call factorize function passing the desired whole number in braces $test->factorize(13); The output is 'Finding factors of 13... 13'; $test->factorize(1024); The output is 'Finding factors of 1024... 2,2,2,2,2,2,2,2,2'; 4) By default class echoes the result, but setting $test->echo=0; will mute the echoes. 5) $factors=$test->factorize(N); syntax returns array of all prime factors of N. If N itself is prime array containing only one factor N is returned. 6) This class comes with a pre-existing data set used for speedy alogorithm which should be kept intact for integrity of results. Any changes in that data-set may result in wiered or falsified results.

  • primefactors.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file pdata Data Data Set for prime factorization
Plain text file primefactors.php Class Class Prime Factors
Accessible without login Plain text file readme.txt Doc. readme
Accessible without login Plain text file test.php Example test page

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:7,911
This week:560Up
 User Ratings  
 All time