Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

135
Visualizações
Detect if JavaScript array of random numbers are all multiples of each other?

I'm generating an array of 5 random numbers. Once generated, I want to ensure that they're all not multiples of each other (super strange edge case). If they are, I want to regenerate them. So I don't want to see [2,4,6,8,10] or [4,8,12,16,20].

How would I detect that?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

The most straightforward way is to sort them and then check to see if the lowest value is a divisor of all of them. If it is, check to see if the next number is a divisor of the ones that come after. etc. etc.

about 4 years ago · Juan Pablo Isaza Relatório

0

Easiest way is to create an array of 100 prime numbers then generate 5 unique numbers under 100 and use this to get the value at the numbered index of the prime numbers array. You will then guarantee the none of the numbers are multiples of each other.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda