2.0

2.0 | 1 rating Rate this file 10 downloads (last 30 days) File Size: 1.17 KB File ID: #4966

factor2.m

by David Terr

 

19 May 2004 (Updated 26 May 2004)

No BSD License  

factor2(n) returns the prime factorization of n as a k by 2 matrix.

Download Now | Watch this File

File Information
Description

Given a nonnegative integer n, factor2(n) returns the prime factorization of n as a 2 by k matrix, with the k distinct prime factors in the left column and exponents in the right column.

MATLAB release MATLAB 6.0 (R12)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
25 May 2004 Jos vdG

or use Matlab:
F = factor(A) ;
X(:,1) = unique(F(:)') ;
X(:,2) = hist(F,X(:,1)) ;

25 May 2004 Jos vdG

Sorry, small mistake in row/columns
F = factor(A) ;
X(1,:) = unique(F(:)') ;
X(2,:) = hist(F,X(:,1)) ;

15 May 2006 Not Happy Jan

Relying on factor() means you restrict yourself to numbers less than 2^32

Please login to add a comment or rating.
Updates
26 May 2004

I modified this program so that it sorts the prime factors by columns instead of by rows, allowing for more convenience, especially with large numbers. I also modified it so it now works with negative numbers as well.

Tag Activity for this File
Tag Applied By Date/Time
symbolic math David Terr 22 Oct 2008 07:20:24
factor David Terr 22 Oct 2008 07:20:24
divisor David Terr 22 Oct 2008 07:20:24
prime factorization David Terr 22 Oct 2008 07:20:24
mathematics David Terr 22 Oct 2008 07:20:24
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com