5.0

5.0 | 1 rating Rate this file 11 downloads (last 30 days) File Size: 1.77 KB File ID: #23066

FACTORADIC

by Darren Rowland

 

22 Feb 2009 (Updated 27 Apr 2009)

Code covered by the BSD License  

Obtain the factorial radix representation of a number.

Download Now | Watch this File

File Information
Description

F = factoradic(M,N) returns the conversion of integer M into factorial radix. F is a 1-by-N vector. The factoradic is also known as the Lehmer Code. The factoradic of M is best understood by example.

            Example: 89 = 3x4! + 2x3! + 2x2! + 1x1! + 0x0!
                    therefore factoradic(89,5) = (3,2,2,1,0)
    
    M must lie in the range [0 : N!-1].
    Leading zeros will be present in F when M < (N-1)!-1.

           Example: factoradic(19,6) = (0,0,3,0,1,0)

A practical use of the factoradic is the generation of permutations. See ONEPERM on the File Exchange.

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
28 Apr 2009 John D'Errico

A useful tool when generating permutations. In fact, I was thinking of putting up this myself. No need to do so now.

Good help. Error checks. Simple engine.

Please login to add a comment or rating.
Updates
27 Apr 2009

Thanks to Stefano Bolli for noticing a typo in the error-checking.

Tag Activity for this File
Tag Applied By Date/Time
factoradic Darren Rowland 23 Feb 2009 11:09:12
factorial radix Darren Rowland 23 Feb 2009 11:09:12
lehmer code Darren Rowland 23 Feb 2009 11:09:12
permutation Darren Rowland 23 Feb 2009 11:09:12
 

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