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

182
Vistas
Invert a sequence in JavaScript

I want to invert this sequence: Invert a function like in mathematics(is this exist in programming) What I mean: if f(x)=y --->g(y)=x so g is the inverse function of f.
My attempt was(but still not working):

function seq(num) {
  
  if(num < 2) {return 1; }
  if(num === 2) {return 2; } 
  
  if(num % 2 === 1) {
    const t = (num - 1) / 2;
    return seq(t - 1) + seq(t) + 1;
  }
  
  const t = num / 2;
  return seq(t) + seq(t + 1) + t;
  
}
document.write(_.invert(seq(4)));
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

There is no known algorithm to programmatically invert a function, baring brute force over the domain. Indeed, such an algorithm, if workable would be a stunning discovery, likely breaking the vast majority of cryptosystems. There are a bunch of different methods for finding the inverse of a function, but they depend on the function in question meeting specific criteria.

The lodash invert function performs an completely different function, swapping keys and values of objects.

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