Mathematical formula for permutation I have been assigned to write mathematical equation for permutation using only 1,3,5,7,9 numbers starting from single digit going up to five digits numbers. For example 
Single digit
1
3
5
7
9
two digit
1,3
1,5
1,7
1,9
Please note  3,1 is treated same as 1,3, or 1,1,3 is same as 1,3,1 and 3,1,1 
Thanks in Advance,
Rodney
 A: The details will depend on the language you are supposed to use. Here is how it could be done in JavaScript: the numbers 1,3,5,7,9 are treated as letters; they get appended to existing strings (oldStrings) as long as this does not put letters out of alphabetical order (e.g., after 15 we cannot put 3 but can put another 5). So there is a triple loop here: one by length of string, one goes over existing strings, and one looks for letters to append, checking the alphabetization condition oldStrings[i].charAt(len-2)<=letters[j]
var letters = ['1','3','5','7','9'];
var oldStrings = [''];
var newStrings = [];
var answer = '';
for (var len=1; len<=letters.length; len++) {
    for (var i=0; i<oldStrings.length; i++) {
        for (var j=0; j<letters.length; j++) {
            if (oldStrings[i].charAt(len-2)<=letters[j]) { 
            newStrings.push(oldStrings[i]+letters[j]);
            }
        }
    }
    answer=answer+'Strings of length '+len+' are '+newStrings.join()+'\n';
    oldStrings = newStrings;
    newStrings = [];
}
alert(answer);​

This is not the most efficient code, but it works. Since this is your assignment, my advice is to re-think and redo the problem in another language (e.g., Python) as to avoid a charge of plagiarism.
