Does it formulate to detect the exact percentage formula that represents a number among a determined total?

-1

I need to find the mathematical formula to find a given percentage number, in the following I leave the code that runs the numbers from 1 to 1000 and determines the number of increasing, decreasing and mixed numbers example 146 is increasing, 952 is decreasing and 592 is mixed, the question is that the results of the program give me the following results:

1000 números
156 son crecientes (15.6%) (Numeros Acumulados que son Creciente)
220 son decrecientes (22%) (Numeros Acumulados que son Decreciente)
525 son Mixtos (52.5%)     (Numeros Acumulados que son Mixtos)

EXAMPLE 2: the expressed code reflects me that the number 538 is just number that represents 50% of the total of the numbers

THE QUESTION IS TO FIND A FORMULA SO THAT ACCORDING TO THE PERCENTAGE, I EXCEED THE EXACT NUMBER AS SHOWN IN EXAMPLE 2.

*************** I hope you can help me, I just need this to finish **************

function DeterminaNumero(numero){
        var num = numero.toString()
        var a = num.split(''); // separa los digitos y los convierte en matriz
        if (a.length == 3) {
            if (a[0] >= a[1] && a[1] >= a[2]) {      
                decrecientes++;             
                return "decreciente: " /*+ decrecientes*100/totalNumeros +"%"*/;
            } else {
                if (a[0] <= a[1] && a[1] <= a[2]) {
                    crecientes++;
                    return "creciente: "/*+ crecientes*100/totalNumeros +"%"*/;
                } else {
                    mixtos++;
                    return "mixto: "+ mixtos*100/totalNumeros +"%";
                }
            }
        }
}

var crecientes=0;
        var decrecientes=0;
        var mixtos=0;
        var totalNumeros=0;

        var optimo=0;
        var min=0;


        for(var i=1;i<=1600000;i++){
            totalNumeros++;
            var resultado = DeterminaNumero(i);
            document.write(i +" es " + resultado +"<br>");
        }

        document.write("------------------------ Resultados ----------------------------<br>");
        document.write(totalNumeros + " números<br>");
        document.write(crecientes + " son crecientes ("+ crecientes*100/totalNumeros +"%)<br>");
        document.write(decrecientes + " son decrecientes ("+ decrecientes*100/totalNumeros +"%)<br>");
        document.write(mixtos + " son Bouncy ("+ mixtos*100/totalNumeros +"%)<br>");
        document.write("------------------------ Numero Minimo ----------------------------<br>");

     //document.write("El Numero minimo para una proporcion Mixta es de 50% es:538 ");
     document.write("Numero Mixto 50% es: "+ min);
    
asked by Yader Yepez 23.11.2018 в 05:45
source

1 answer

0

Good morning, if I really apologize if you write the question wrong here is what I want: Of this code  mixed ++;

if (mixed * 100 / totalNumbers == 50) {                     min = (50 * totalNumbers) / 100;                     optimal = min                 }

I want to know the formula that gives me exactly the number that represents 50%, when I run the program this number is 538, but I can not find the way to visualize it automatically, what I want is a formula that finds it, store it in a variable and then show it as a result.

function DeterminaNumero(numero){
        var num = numero.toString()
        var a = num.split(''); // separa los digitos y los convierte en matriz
        if (a.length == 3) {
            if (a[0] >= a[1] && a[1] >= a[2]) {      
                decrecientes++;             
                return "decreciente: " /*+ decrecientes*100/totalNumeros +"%"*/;
            } else {
                if (a[0] <= a[1] && a[1] <= a[2]) {
                    crecientes++;
                    return "creciente: "/*+ crecientes*100/totalNumeros +"%"*/;
                } else {
                    mixtos++;
                    if (mixtos*100/totalNumeros==50) {
                        min=(50*totalNumeros)/100;
                        optimo=min
                    }
                    return "mixto: "+ mixtos*100/totalNumeros +"% ";
                }
            }
        }
}

var crecientes=0;
        var decrecientes=0;
        var mixtos=0;
        var totalNumeros=0;

        var optimo=0;
        var min=0;


        for(var i=1;i<=1000;i++){
            totalNumeros++;
            var resultado = DeterminaNumero(i);
            document.write(i +" es " + resultado +"<br>");
        }

        document.write("------------------------ Resultados ----------------------------<br>");
        document.write(totalNumeros + " números<br>");
        document.write(crecientes + " son crecientes ("+ crecientes*100/totalNumeros +"%)<br>");
        document.write(decrecientes + " son decrecientes ("+ decrecientes*100/totalNumeros +"%)<br>");
        document.write(mixtos + " son Bouncy ("+ mixtos*100/totalNumeros +"%)<br>");
        document.write("------------------------ Numero Minimo ----------------------------<br>");

     //document.write("El Numero minimo para una proporcion mixto es de 50% es:538 ");
     document.write("Numero Mixto 99% es: "+ min +" "+ optimo);
    
answered by 23.11.2018 в 15:42