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

90
Views
Invert sequence

I'm trying to invert the sequence: (seq), I built a new function (mos) but still not working, any suggestion or trick.

function seq(num) {
  
  if(num < 2) {return 1; }
  if(num === 2) {return 2; } 
  
  if(num % 2 === 1) {
    const t = (num - 1) / 1;
    return seq(t - 1) + seq(t) + 1;
  }
  
  const t = num / 2;
  return seq(t) + seq(t + 1) + t;
  
};
function mos(q) { var i; for (let i = 2; i < 1000; i++) { if(seq(i-2)===q){return i;}}
    
}; document.write("mos(15): "+mos(22)+"<br>");```
about 4 years ago · Juan Pablo Isaza
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!