Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

212
Vistas
Calculator: Faculty and eulers number

I have to program a calculator which can calculate a faculty and a eulerian number. these formulars are given:

                       faculty: Number1! = 1*2*...*Number1
                       eulerian number:   Number1
                                       e=    ∑   1/k!
                                            k=0

I have most of the code, but I don't know how to use thes formulars in my code.

<label for="zahl1"></label>
<input id="zahl1" type="text" placeholder="Zahl eingeben">
<label for="zahl2" type="text"></label>
<input id="zahl2" type="text" placeholder="Zahl eingeben"> <br>
<button id="facultyBtn" class="btn btn-info">F</button>
<button id="eulerschBtn" class="btn btn-info">e</button>
document.getElementById("facultyBtn").addEventListener("click", () => {
        const zahl1Input = document.getElementById("zahl1");
        const zahl2Input = document.getElementById("zahl2");
        const zahl1 = Number(zahl1Input.value);
        const zahl2 = Number(zahl2Input.value);
        const F = 

        let ergebnis;
        ergebnis = F

        const ergebnisInput = document.getElementById("ergebnis");

        ergebnisInput.innerText = ergebnis.toString();
    })

    document.getElementById("eulerschBtn").addEventListener("click", () => {
        const zahl1Input = document.getElementById("zahl1");
        const zahl2Input = document.getElementById("zahl2");
        const zahl1 = Number(zahl1Input.value);
        const zahl2 = Number(zahl2Input.value);
        const e = 

        let ergebnis;
        ergebnis = e

        const ergebnisInput = document.getElementById("ergebnis");

        ergebnisInput.innerText = ergebnis.toString();
    })
})

So what I am missing in my code is what to write after "const f =" and "const e =" I would really appreciate some help. I am new to programming, but I have to finish this for school.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

This is factorial (faculty), it's a classic:

function faculty(number) {
  total = 1;
  for (var i = 1; i <= number; i++) {
    total = total * i;
  }
  return total;
}
console.log (faculty(3))

As for eulerian number this is from geek4geeg.

function eulerian(n, m) {
  if (m >= n || n == 0)
    return 0;

  if (m == 0)
    return 1;

  return (n - m) * eulerian(n - 1, m - 1) +
    (m + 1) * eulerian(n - 1, m);
}

console.log(eulerian(4, 2))

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda