
//function for unique Question
function populate(array1, array2, length) {

    while (array2.length < length) {
        var randomImageData = Math.floor(Math.random() * array1.length);
        if (array2.indexOf(randomImageData) == -1) {
            array2.push(randomImageData);
        }
    }
    return array2;
}


function shuffle(sarray) {

    var arrayLength = sarray.length;
    var temp, random_index;
    while (arrayLength > 0) {
        random_index = Math.floor(Math.random() * arrayLength);
        arrayLength--;
        temp = sarray[arrayLength];
        sarray[arrayLength] = sarray[random_index];
        sarray[random_index] = temp;
    }

    return (sarray);
}
 function primeFactor(n , array2)
 {
    // Print the number of 2s that divide n
        while (n%2 == 0)
        {
            console.log(2);
            array2.push(2);
            n = n/2;
        }
     
        // n must be odd at this point.  So we can skip
        // one element (Note i = i +2)
        for (var i = 3; i <= (n/2); i = i+2)
        {
            // While i divides n, print i and divide n
            while (n%i == 0)
            {
                console.log(2);
                array2.push(i);
                n = n/i;
            }
        }
     
        // This condition is to handle the case when n
        // is a prime number greater than 2
        if (n > 2)
        array2.push(n);
        //console.log(n);
        return(array2);
}

function numberSplit(number) {
    var no_array = [], noOfDigit, numberWithCouma = "";

    number = number.toString();
    no_array = number.split("");
    noOfDigit = no_array.length;
    index = noOfDigit - 3;
    i = no_array.length - 1;

    while (index > 0) {
        no_array[index] = "," + no_array[index];
        index = index - 2;
    }
    for (i; i >= 0; i--) {
        numberWithCouma = no_array[i].concat(numberWithCouma);
    }
    return numberWithCouma

}

