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);