This code runs for infinity, why?
function f(n){
i=0;
if (n==2){
while(i<2){
f(i);
i++;
}
}
}
if n!=2 the function should do nothing and if n equals 2 the function calls f(0) and f(1) so it should stop after that but you only get infinite loop when you run it.
any one could tell why?
edit: there is nothing outside the function.
and no need for better code.Just asking why.