We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • HackerRank Home

    HackerRank

  • |
  • Prepare
  • Certify
  • Compete
  • Apply
  • Hiring developers?
  1. Prepare
  2. Algorithms
  3. Warmup
  4. Solve Me First
  5. Discussions

Solve Me First

Problem
Submissions
Leaderboard
Discussions
Editorial

    You are viewing a single comment's thread. Return to all comments →

  • dkunfchaworl
    5 months ago+ 1 comment
    function solveMeFirst(a, b) {
      // Hint: Type return a+b below   
      let sum=Math.round(Math.pow(10,10)*Math.random())
        let maybeB = sum - a
     
     
     do{
         if(maybeB>b)sum=Math.round(sum/2)
         else sum=sum*3
        //  console.log(sum)
         maybeB=sum-a
     }while (maybeB != b)
    //  console.log("sum: ",sum)
     return sum
    }
    
    0|
    Permalink
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy