Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

134
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!