-1

Below is my script

var num=1;
var validator =false;

while(!validator){
   for(var k=1;k<=N;k++)
   {
      if(num%k==0)
      {
        validator = true;
      }
      else
      {
        validator = false;
        break;
      }
    }
    num = num+1;
}
console.log("number is: "+parseInt(num-1));

The above code gives the result when N=10 i.e "the number is: 2520" But when i change the value of N=20, the script stops responding. Can anybody explain me why so & how can i determine till what level of computational complexity Javascript can compute. Thanks.

Kaf
  • 33,101
  • 7
  • 58
  • 78
subh
  • 327
  • 1
  • 3
  • 6

1 Answers1

1

No it executes but the performance is getting affected, because of the while looping.

number is: 232792560 //when N=20
Praveen
  • 55,303
  • 33
  • 133
  • 164