Here is my solution. it's not the cleanest but is quite fast and it seems to work. I used nodeJS
functioncheckDivisible(number){if(number%20==0&&number%19==0&&number%18==0&&number%17==0&&number%16==0&&number%15==0&&number%14==0&&number%13==0&&number%12==0&&number%11==0&&number%10==0&&number%9==0&&number%8==0&&number%7==0&&number%6==0&&number%5==0&&number%4==0&&number%3==0&&number%2==0&&number%1==0){returntrue;}else{returnfalse;}}functionmain(){letdone=false;letc=1;console.log(`c = ${c}, incrment = ${c}`);letstartTime=Date.now();while(!done){if(checkDivisible(c)){console.log(`${c} is Divisible by 1 - 20 with no remainder`);done=true;}c++;}letendTime=Date.now();console.log(`Time Taken: ${Math.round(endTime-startTime)}ms`);}main();
here is the output
c = 1, incrment = 1
232792560 is Divisible by 1 - 20 with no remainder
Time Taken: 607ms
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Here is my solution. it's not the cleanest but is quite fast and it seems to work. I used nodeJS
here is the output